Php create event google calendar
I got it to work using a service account and some steps based on this answer, here is what I did: Show 1- Create a project on Google Developer Console. 2- Go to Credentials and create a Service account key with key type JSON, a JSON file will be downloaded, move it to your project folder. 3- Enable Calendar API from Library tab, search for Calendar API and enable it. 4- Go to your Google Calendar 5- Go to Settings -> Add calendar -> New calendar, after that a notification/toast will popup click on Configure, scroll down to Share with specific people -> Add people, on the email field add the service account ID, you can get it from Credentials -> Manage service accounts then set the Permission to Make changes to events and click Send. 6- Download the PHP client library. 7- Now you need to get the calendar ID, from calendar settings scroll down to last section you will find it, or here is a sample code to get it, look for it in the response, it will be something like this '':
8- You can now add events to the calendar, sample code:
What happens here is that the event is created by the service account which is different than your own google account and has it's own data so if you didn't share the calendar with the service account and set the calendar id to primary it will create the event on the service account calendar which you can't access it normally. I hope this helps anyone. References:
How do I get Google Calendar events in PHP?A Google account with Google Calendar enabled.. Step 1: Install the Google Client Library. composer require google/apiclient:^2.0. ... . Step 2: Set up the sample. Create a file named quickstart.php in your working directory and copy in the following code: ... . Step 3: Run the sample. Run the sample using the following command:. How do I create a Google Calendar event?Event options. On your computer, open Google Calendar.. In the top left corner, click Create .. Add a description for your event.. Under the date and time, check the box next to All day.. Click Save.. How do I add an event to my Google Calendar from a website?Generate a URL to Add Events to Google Calendar. Open your Google Calendar and select the event you want to share.. Click the three dots to open the option menu.. Click “Publish event”. Copy the URL and paste the link on any platform you want.. Is Google Calendar API free?All use of the Google Calendar API is available at no additional cost.
|