I'm trying to clear the contents of a secondary Google Calendar in PHP but I see in the API documentation that the clear() method only works on the accounts primary calendar and wont take parameters for a secondary calendar calendar ID. Instead it says to use the delete() method but I do not want to delete the calendar all together, just delete its contents.
//legal
$service->calendars->clear('primary');
//Illegal
$service->calendars->clear($calendarId);
What would be the most effective way to clearing the events of a secondary calendar in the API?
You can actually delete events from your secondary calendar like you would in your primary. Use the Events: delete and provide the calendarid and eventId. But, take note that in your secondary calendar, your calendarId is no longer your default email. It's different. (Calendar-> calendar settings -> Calendar Address )
You can give it a Try-it to test this.
Related
How can I get the calendar of a particular user?
Im working on a Podio-to-calendar implementation and want to do that, but so far, I had no positive results.
I can get all the events for workspace, app, etc using the examples and documentation in https://developers.podio.com/doc/calendar .
Is there any calendar method to get the data for a user across Podio?
In that case, can I get even the data that has been synced from another calendar, like the one in my google account? I have the feeling that those events are not saved as podio items at all, am i right?
For getting global calendar I'd start with https://developers.podio.com/doc/calendar/get-global-calendar-22458 method.
For linked account's calendars, you are right - Podio doesn't import event from them as items, they are only displayed on calendar. To get those you should use: https://developers.podio.com/doc/calendar/get-linked-account-calendar-78081299. And to get linked account, you will need this one: https://developers.podio.com/doc/linked-accounts
Using Office 365 REST API I can easily read the main calendar of a given account. A simple example using PHP is given here.
But how do I read the secondary calendars like "test" shown in the screenshot below? Events from secondary calendars don't show up in the API requests. Somehow it makes sense that I must tell the API which calendar I want to access (there could be many of them), but where or how in the API call do I do that?
I found the answer here:
Get a collection of series master and single instance events from the
user's primary calendar (../me/events) or from a different calendar.
GET
https://outlook.office.com/api/v2.0/me/calendars/{calendar_id}/events
where {calendar_id} is the ID of the calendar you wish to access.
You can find how to obtain the ID in this answer.
It works.
I'm working with Google calendar API, all my site is about to manage my appointments.
Now I'm integrating Google calendar to my site, so if I add or update any from my site the same are going to change in my Google calendar. If I change details in calendar I need to get my site DB updated via Push mechanism. Now I've established connection/mechanism to update the event details so if I change the date/time in my calendar my code is changing my DB with respect to Google calendar new date/time on that event via Push.
But I'm not sure how to delete any event which I delete in my calendar, for example:
If I delete an existing appointment in my calendar, that needs to be deleted in my DB too so it wont list on my appointment list.
Can someone help me how to track event deletion from Google API?
Is there a flag to notify at all?
Deleted events have status set to "cancelled".
If you want to also have cancelled events included in the events list requests, you should specify showDeleted=true as a request parameter.
Check out the documentation for details
https://developers.google.com/google-apps/calendar/v3/reference/events/list
I am creating a php website that uses the Google Calendar API. It's working fine with Create, Update and Delete: any event from the PHP website goes into my Google Calendar events after login.
Events created on my site are created in Google Calendar.
What I want now that is: when I create an event from my test page it goes into Google Calendar after login, then if I update or delete that event from Google Calendar then it should automatically update or delete the php website event.
Basically: 1-way sync is working fine but now I want 2-way synchronization.
If anybody has any ideas then kindly share with me, it will be much appreciated.
There are no application hooks in Google Calendar (gCal) that allow you to trigger an action when an event is deleted. Instead you must either poll gCal at intervals (this could be a cron job every few minutes/hours) and update your calendar accordingly, or any time you perform an action from your calendar have a 1 in X possibly of a full re-sync.
This implies that you are using the gCal as the definitive source, and mirroring those changes back to your local application.
well, after following these answers and building a hole 2 way sync process,
i realized there's a push notifications for calendar since 2013.
you will still need a full sync process because the push notification only notifies about a change but no data about the change.
hope it will save you some time.
Push Notifications
Would it not be an option for your system to generate an iCal output at a special, user-specific URL, and then have the user subscribe to that calendar in Google Calendars (or their iCal-reading calendar of choice)?
That way, your system would always hold the authorative calendar, and Google Calendar would reflect any changes you make automatically.
Alternately, if you are wanting changes in the Google Calendar to be reflected in your application, then you may be able to subscribe to iCals for the User's Calendar, and then poll them at a regular interval to reflect any changes the User has made at that end.
I would lean towards the first option (your iCal subscribed through Google Calendar), as it is a simpler and easier solution.
I have successfully saved all the events from my custom calendar to Google calendar with PHP script. But whenever i try to sync same calendar again, i see all the events are recreated & duplicated. Is their any Google Calendar API clue that might help remove the duplication?
Please help.
Regards.
I am asuming you are using the iCal interface.
We did a similar implementation a while back (not using php but anyways).
What we used to keep this duplication away was that after we had created a new event in the google calendar we fetched from google and found this event. Then we keept track of the "CREATED" part of the iCal file that we got back from google, and simply used this as a reference to know both what have been synced and to be able to link items in google calendar and our side.