Wrong URL ????

Wrong URL ????

hello,

I have built the interface to the "Calendar".

See attachment 1.

The updating of the token when the time has expired is also successfully implemented. (will be automated later in the query)

Only here I have a problem.
https://www.zoho.com/calendar/help/api/get-calendar-list.html

I have attached my PHP code once as a TXT attachment.
As well as its response as an image. Attachment 2:

"Invalid URL

Unable to process your request as the URL /calendar/api/v1/calendars?category=all&showhiddencal=true is invalid."


What am I doing wrong or is the documentation no longer correct?

Many thanks for your help.

  1. <?php

    function fetch_and_renew_token() {
        $client_id = NMT::sqlObject("SELECT `val` FROM `nmt-cfg` WHERE `key` = 'zoho_client_id'; ")->val;
        $client_secret = NMT::sqlObject("SELECT `val` FROM `nmt-cfg` WHERE `key` = 'zoho_client_secret'; ")->val;
        $refresh_token = NMT::sqlObject("SELECT `val` FROM `nmt-cfg` WHERE `key` = 'zoho_refresh_token'; ")->val;

        if (!empty($client_id) && !empty($client_secret) && !empty($refresh_token)) {
            $url = 'https://accounts.zoho.eu/oauth/v2/token';
            $data = [
                'refresh_token' => $refresh_token,
                'client_id' => $client_id,
                'client_secret' => $client_secret,
                'grant_type' => 'refresh_token'
            ];

            $response = custom_curl_request($url, $data);

            if (isset($response['access_token'])) {
                $access_token = $response['access_token'];
                $expires_in = $response['expires_in'];
                $api_domain = $response['api_domain'];
                $expires_at = time() + $expires_in + 7200; // +2 Stunden

                NMT::sqlDo("INSERT INTO `nmt-cfg` (`key`, `val`) VALUES ('zoho_access_token', '$access_token') ON DUPLICATE KEY UPDATE `val` = '$access_token';");
                NMT::sqlDo("INSERT INTO `nmt-cfg` (`key`, `val`) VALUES ('zoho_token_expires_at', '$expires_at') ON DUPLICATE KEY UPDATE `val` = '$expires_at';");
                NMT::sqlDo("INSERT INTO `nmt-cfg` (`key`, `val`) VALUES ('zoho_api_domain', '$api_domain') ON DUPLICATE KEY UPDATE `val` = '$api_domain';");

                return $access_token;
            } else {
                echo '<div style="color: red;">Fehler bei der Token-Erneuerung.</div>';
                echo '<pre>' . print_r($response, true) . '</pre>';
                return null;
            }
        } else {
            echo '<div style="color: red;">Fehler: Client ID, Client Secret oder Refresh Token fehlen.</div>';
            return null;
        }
    }

    function custom_curl_request($url, $data = [], $type = 'POST', $headers = []) {
        $curlOpts = [
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2TLS,
            CURLOPT_CUSTOMREQUEST => $type,
            CURLOPT_SSL_VERIFYPEER => FALSE,
        ];

        if ($type === 'POST' && !empty($data)) {
            $curlOpts[CURLOPT_POSTFIELDS] = http_build_query($data);
        }

        if (!empty($headers)) {
            $curlOpts[CURLOPT_HTTPHEADER] = $headers;
        }

        $request = curl_init();
        curl_setopt_array($request, $curlOpts);
        $response = curl_exec($request);
        $curl_error = curl_error($request);
        $http_code = curl_getinfo($request, CURLINFO_HTTP_CODE);
        curl_close($request);

        if ($curl_error) {
            echo '<div style="color: red;">Curl Error: ' . htmlspecialchars($curl_error) . '</div>';
        }

        echo '<div>HTTP Code: ' . htmlspecialchars($http_code) . '</div>';
        echo '<div>Request URL: ' . htmlspecialchars($url) . '</div>';
        echo '<div>Request Headers: ' . htmlspecialchars(print_r($headers, true)) . '</div>';
        
        if ($http_code >= 400 && $http_code < 600) {
            echo '<div>Raw Response: ' . $response . '</div>';
        } else {
            echo '<div>Raw Response: ' . htmlspecialchars($response) . '</div>';
        }

        return json_decode($response, TRUE);
    }

    function fetch_calendars() {
        $access_token = NMT::sqlObject("SELECT `val` FROM `nmt-cfg` WHERE `key` = 'zoho_access_token'; ")->val;
        $api_domain = NMT::sqlObject("SELECT `val` FROM `nmt-cfg` WHERE `key` = 'zoho_api_domain'; ")->val;

        if (!empty($access_token) && !empty($api_domain)) {
            echo '<div>Verwendeter Access Token: ' . htmlspecialchars($access_token) . '</div>';
            echo '<div>Verwendete API Domain: ' . htmlspecialchars($api_domain) . '</div>';

            $url = $api_domain . '/calendar/api/v1/calendars?category=all&showhiddencal=true';
            $headers = [
                "Authorization: Bearer $access_token"
            ];

            $curl_command = "curl -X GET \"$url\" -H \"Authorization: Bearer $access_token\"";
            echo '<div>Curl Command: ' . htmlspecialchars($curl_command) . '</div>';

            $response = custom_curl_request($url, [], 'GET', $headers);

            if (isset($response['calendars'])) {
                echo '<div>Kalender erfolgreich abgerufen:</div>';
                echo '<pre>' . print_r($response['calendars'], true) . '</pre>';
            } else {
                echo '<div style="color: red;">Fehler beim Abrufen der Kalender.</div>';
                echo '<pre>' . print_r($response, true) . '</pre>';
            }
        } else {
            echo '<div style="color: red;">Fehler: Access Token oder API Domain fehlt.</div>';
        }
    }

    if (isset($_POST['fetch_calendars'])) {
        fetch_calendars();
    }

    if (isset($_POST['fetch_token'])) {
        fetch_and_renew_token();
    }
    ?>

    <form method="post" action="">
        <input type="submit" name="fetch_token" value="Fetch-Token" />
        <input type="submit" name="fetch_calendars" value="Kalender abfragen" />
    </form>

    Access your files securely from anywhere







                            Zoho Developer Community




                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts



                                                        • Topic Participants

                                                        • test

                                                            • Sticky Posts

                                                            • The year that was at Zoho Calendar 2023- Part 1

                                                              Hello, amazing community members! Happy new year from all of us here at Zoho Calendar. As we begin the new year, we'd like to thank each and everyone of our community members for your unwavering support and love that you have shown for Zoho Calendar.
                                                            • Zoho Calendar 2024: A Year in Review

                                                              Hello, community members! Happy new year from all of us here at Zoho Calendar. As we turn the page to a new year, we extend our heartfelt gratitude to every member of our Zoho Calendar community for your continued support and enthusiasm. Your feedback
                                                            • What's new in Zoho Calendar!

                                                              Hello all, Greeting from Zoho Calendar! Hope you are all doing well! We at Zoho Calendar are constantly striving to improve our Calendar to enhance your overall calendaring experience thanks to your insightful suggestions and feedback. In the last few
                                                            • Enhancements to make Zoho Calendar more accessible and handy!

                                                              Hello, Community! Hope you're all doing well! Zoho Calendar have come across a major revamp a year back. Since then the feedback and suggestions given by you made us to improve and enhance Calendar, to make it more accessible and user friendly. We've
                                                            • Important announcement: Deprecation of Zoho Calendar's old interface

                                                              Hello All! Thank you all for the amazing welcome to the release of the new Calendar. Here are some comments about the new interface that motivated us:  Many of our users who were using the older version for a long period, loved the new Calendar, as it


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner









                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources

                                                                                              Zoho Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ



                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                              • Recent Topics

                                                                                                              • Is it possible to embed Youtube shorts?

                                                                                                                Hi Zoho desk support, This is Ryan from Accuver America. While I'm trying to create a knowledge base article with embed video, I ran into this issue. "www.youtube.com refuse to connect" A little bit background is that because this video is recorded on
                                                                                                              • Split functionality - Admins need ability to do this

                                                                                                                Admins should be able to split an expense at any point of the process prior to approval. The split is very helpful for our account coding, but to have to go back to a user and ask them to split an invoice that they simply want paid is a bit of an in
                                                                                                              • Delegates - Access to approved reports

                                                                                                                We realized that delegates do not have access to reports after they are approved. Many users ask questions of their delegates about past expense reports and the delegates can't see this information. Please allow delegates see all expense report activity,
                                                                                                              • How to include total km for multiple trips in expense report.

                                                                                                                Whenever I create a mileage report it only shows the total dollar amount to be reimbursed. The mileage for each individual trip is included but I also need to see the total distance for all trips in a report? How do I do this?
                                                                                                              • I didn't receive my domain verification mail

                                                                                                                I didn't receive my domain verification mail 
                                                                                                              • Get logged in user ID in Deluge script

                                                                                                                Hello all, How do I get the id of the logged-in user in a deluge script? the "zoho.loginuserid" function actually returns the users email address or whatever the user id they use to login to zoho with and not the id of the user record, and given that
                                                                                                              • Item Details Field - New Barcode / Document option?

                                                                                                                Is this a new feature??? its in both books and inventory.
                                                                                                              • Shared Mailbox - Mark as read for all users

                                                                                                                Hi all, Maybe someone can help me out. At the moment we have a shared mailbox without streams. When a users reads an mail or marks it as read other users will not see this. How can we resolve this? We now archive the mails when read and followed up. However
                                                                                                              • Can I export to PDF in Zoho Learn

                                                                                                                I have seen help pages where export to pdf options are available but I do not see that option available from the application. I see that exprt is available in my free trial version but that is only to html pages. I need to be able to export my manuals
                                                                                                              • Staff rules

                                                                                                                Hi! Do you people know what are the default staff rules when a new booking is created? We have two staff members in my team (me as the admin, and my employee). As we share the same services, I'm wondering how Zoho will pick the staff for new apointments.
                                                                                                              • Add Image Upload Field to Zoho Bookings Registration Form

                                                                                                                Hi, We would like to request the addition of an image upload field to the Zoho Bookings registration form. Currently, Zoho Bookings only supports text-based fields (e.g., Single Line, Multi-Line, Email, Checkbox, Dropdown, Radio Button, and Date), but
                                                                                                              • Merge Tags Output Incorrect Placeholder Text After CRM Sync

                                                                                                                Hi everyone, I’m experiencing an issue with merge tags in Zoho Campaigns after last sync of contacts and leads from Zoho CRM (days before everything worked perfectly). Here’s the situation (seems like a default configuration in Campaigns) : My leads have
                                                                                                              • Windows agent 2025_M02 release notes

                                                                                                                Agent Version: 111.0.3.300 Release date: 24 February, 2025 Various Major enhancements to improve overall performance and optimize the user experience. Squashed a few bugs to improve overall product quality.
                                                                                                              • Windows agent 2025_M01 release notes

                                                                                                                Agent Version: 111.0.3.299 Release date: 05 February, 2025 Major Enhancement: Live Monitor feature compatibility released. Major Enhancement: Updated Scaling for multi technician cases with Android and Web based viewers. Various other bug fixes and performance
                                                                                                              • how to record deferred revenue?

                                                                                                                Dear Zoho Team, We issue invoices relating to 12-month web hosting service. When we issue the invoice, we should record the entire amount of the invoice as DEFERRED REVENUE (ie. $10 x 12 mths = $120, balance sheet item). After the particular month of the hosting service, $10 of revenue has been earned and deferred revenue amount will be $110. We must keep adjusting the balance sheet and income statement over the course of the service until the company has fulfilled its obligation of services and
                                                                                                              • Narrative 13: Importing your data

                                                                                                                Behind the scenes of a successful ticketing system: BTS Series Narrative 13: Importing your data When importing data into an application, it is crucial to prevent data loss or duplication. These types of errors can hinder the development of a clean and
                                                                                                              • Blueprint Not Triggering When Lead Status Is Updated by Workflow (IndiaMART Integration)

                                                                                                                I have set up a blueprint that triggers when a lead’s status is “New Lead.” Our CRM is integrated with IndiaMART, and when leads are created from IndiaMART, their Lead Status is initially set to None. To handle this, I created a workflow that automatically
                                                                                                              • Update Subform in specific field(Status) without affecting other fields in Zoho CRM using Deluge?

                                                                                                                Scenario: PRODUCT Module(change name Plot) in any product status change From Available to Booked then on PROJECT Custom Module have Subform So, Subform name is Property Details now in that Subform 1 field is STATUS that update according to  product status
                                                                                                              • YouTube Live #2: Agreement Intelligence with Zoho Sign's eSign AI assistant

                                                                                                                Hi there, We're back again with our YouTube live series and this time, we'll take you through our holistic agreement intelligence powered signature workflows. Struggling to draft an agreement? Need help double-checking clauses and going through complicated
                                                                                                              • Can I Build a POS using ZOHO creator and integrate it with ZOHO Books?

                                                                                                                Hello,  I have a Zoho Books account and I was wondering if I can have a POS system that integrates with it. Primarily with Inventory, Customers and Payment and ofcourse Create invoices and credit notes.   So, would Zoho creator provide me with this solution?  Thank you, 
                                                                                                              • An important update for Zoho Cliq desktop users

                                                                                                                The latest version of the Zoho Cliq desktop app (v1.8.0) will no longer be supported on macOS 10.15 Catalina and earlier versions. This is because the framework we use (Electron) no longer supports some older macOS versions. If you’re using macOS 10.15
                                                                                                              • New Toolbar in Zoho Sheet

                                                                                                                We have revamped our toolbar design in this new version of Zoho Sheet. Below are some screenshots to help you get accustomed to this new interface. Click on the picture below to view the animated image in its original size. Scroll down this post to learn about the changes. Highlight of Changes: The previous format tab is now split into 2 tabs - Home and Format. The Home tab contains the commonly used functions and the Format tab holds formatting related options. Under the Home tab towards the far
                                                                                                              • Zoho inbuilt Telephony made a lot of issues!

                                                                                                                Hi there, I am a user that I am working with zoho inbuilt telephony around 1 month. Non of my colleagues are happy with this app! most of the time customer cannot hear my customer service team, customers say our voice is breaking. whenever Telephony support
                                                                                                              • Sending workflow notifications using popular chat services

                                                                                                                Hello everyone, We have introduced instant and scheduled notifications on some of the most popular chat platforms to facilitate easy collaboration, quick action, and wider reach. Workflow notifications can be sent to the following chat platforms: Zoho
                                                                                                              • Adding Images to a Quote in Zoho CRM

                                                                                                                We are currently preparing to use Quotes in Zoho CRM and we are building out our Quote templates.  We came across an issue of not being to add Images of the products to the Quote - specifically in the body of the Quote templates.   This is a problem,
                                                                                                              • Applications built with Zoho Creator

                                                                                                                Hi, I’m really interested in seeing how others have built their application using Zoho Creator, especially those designed for external users (clients, vendors, or the public). If you’ve developed something along those lines and don’t mind sharing, I’d
                                                                                                              • Is it posssible to add Asap Widget on Wordpress?

                                                                                                                I have tried to add the ASAP widget so users could iniciate chats and see the KB information but nothings seems to work. I have tried to add the script using a php snippet that adds the to the footers and also tried one for the header in the functio
                                                                                                              • Require ticket resolution

                                                                                                                Hi Zoho team, Is there a way to require resolution even if an agent did not use a blueprint? for example, our blueprint has a "resolve" transition but what if agent revoked blueprint and manually set the status of ticket to closed? Is there a way where
                                                                                                              • Tables from ZohoSheets remove images when updated from source

                                                                                                                I have a few tables from a ZohoSheet in a ZohoWriter document that will remove the images in the cells when I refresh from the source. The source still has the images in the table when I go to refresh. After updating from the source, as you can see the
                                                                                                              • API Pagination Error: 'from' Parameter Limit

                                                                                                                Hello, I am encountering an error while paging through the Zoho Desk API results: Status code: 422 - {"errorCode":"UNPROCESSABLE_ENTITY","message":"The value passed for field 'from' exceeds the range of '0-4999'."} Is 5000 the maximum number of records
                                                                                                              • How to go to the next open ticket in the queue when agents closes ticket

                                                                                                                Zoho Desk When agent closes a ticket - eg when they choose 'Send and Close" - where is the setting that automatically redirects them to the next open ticket in the queue?
                                                                                                              • CRM verify details pop-up

                                                                                                                Was there a UI change recently that involves the Verify Details pop-up when changing the Stage of a Deal to certain things? I can't for the life of me find a workflow or function, blueprint, validation rule, layout rule ect that would randomly make it
                                                                                                              • Custom templates for calendar report

                                                                                                                What about being able to design custom templates for the calendar report, as well as for other types of reports? I think more users are waiting for this.
                                                                                                              • Disable payment thank-you emails

                                                                                                                Hello, can someone please tell me how to disable sending of the "Payment Thank-You" emails? 
                                                                                                              • Maximum tags possible in Contacts Records

                                                                                                                I read in some documentation that Zoho allows a total of 200 tags across all records. Is this correct? So is it not possible to have one tag per record for 500 records?
                                                                                                              • Any way to "Pay with Check" or "Refund with Check" for Credit Notes?

                                                                                                                When we have a Bill in Zoho Books, we can select the "Pay with Check" option which then allows us to print/cut the check directly out of Zoho Books. When we created a Credit Note and want to refund the customer, is there any way to Refund with Check,
                                                                                                              • CRM Mobile reports

                                                                                                                When our engineers finish a job they like to email the customer a job report. This is best done todate as an email template but we can find no way to include an image field from that module. Is there any other options?
                                                                                                              • When Zoho Tables Beta will be open to EU data center

                                                                                                                Hello all, We in EU are looking at you all using and testing and are getting jealous :) When we will be able to get into the beta also? We don't mind testing and playing with beta software. Thank you!
                                                                                                              • Start Form on a different page (i.e., hide form pages)?

                                                                                                                I have a Zoho form that uses the `Field Alias - Prefill URL` feature. My goal is to have a pre-filled field that directs the user to a specific starting page in the form. For example: The URL will have a field alias that will auto-populate a field with
                                                                                                              • How can we disable "My Requests"?

                                                                                                                We are not using this functionality in our system at all and our users get confused.
                                                                                                              • Next Page