Google US Holidays Calendar Feed Forbidden

喜欢而已 提交于 2019-12-12 09:59:54

问题


I was pulling in US holidays using this google calendar feed...

https://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/full?alt=json-in-script&callback=jQuery18204341156887821853_1416248123466&start-min=2014-10-26T00%3A00%3A00Z&start-max=2014-12-07T00%3A00%3A00Z&singleevents=true&max-results=9999&_=1416248372436

It now returns Forbidden Error 403. I'm assuming this has to do with v2 being shutdown today: https://developers.google.com/google-apps/calendar/v2/developers_guide_protocol

I can't find how to get this feed with v3. Does anyone know?

UPDATE: It appears I am not using the URL above, I am actually using this URL: https://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic

And it appears to work. The bug seems to be with the "fullcalendar" jQuery plugin I am using. It is taking this URL that works and turning it into the initial one I posted that does not work. I will investigate further and see if the fullcalendar has a patch or new version.


回答1:


To make this work with v3, just register for a developer key at https://console.developers.google.com and then do:

GET https://www.googleapis.com/calendar/v3/calendars/usa__en%40holiday.calendar.google.com/events?key={YOUR_API_KEY}




回答2:


I went through the same problem today.My client has been using fullcalendar for a while now. The problem seems to be that Google shut down the API (v1, v2)

http://googleappsupdates.blogspot.ca/2014/06/calendar-gdata-api-google-calendar.html

I have been working on making it compatible with the v3. I uploaded the files you may need here:

http://dev.radicalwerks.com/RadicalCalendar/rwCal/fullcalendar.js

and

http://dev.radicalwerks.com/RadicalCalendar/rwCal/gcal.js

Here you can see the example working:

http://dev.radicalwerks.com/RadicalCalendar/my_fgcalendar.html

There is a few steps you need to do in order to enable the API and make it work.

First of all create a client ID and get a Key from the developer console of google:

https://console.developers.google.com/project

In order to do that, create project, go to credentials under APIs & Auth etc. When you get the client ID, keep the AUTHORIZED REDIRECT URIS textarea blank. Add the domain where you need to run the API under JAVASCRIPT ORIGINS (you can use several domains adding one per line). You might know all of this but could help to others who does not have a clear idea of how it works.

Once you get the client ID and Key you have to add them into the variables located in the fullcalendar.js file. They are on top:

var clientId

var apiKey

Keep the scope value. Finally you need to get the calendar ID (located beside the XML badge under calendar settings / Calendar Details / Calendar Address. You have to add it in the object we usually use to add the url. You will not need the url anymore. You need to add a new property called "calendarId". If you check the live example under http://dev.radicalwerks.com/RadicalCalendar/my_fgcalendar.html you can see how I added mine.

One last thing you need to load the API by adding on the head:

<script src="https://apis.google.com/js/client.js"></script>    

All the additions I did in those 2 files are between comments: /* New update by Yared */

I have to improve the code, it is just a quick fix to make it work. Now it is time to sleep :) I will probably update the code soon. Basically, so you know, I interrupted the AJAX call if is detecting the property CalendarID and then I am making a request using the API v3 and adjusting the events object according to the new format.

I think I am not missing anything. I hope all of this helps.




回答3:


Not sure if this is equivalent since I can't see the original, but try: https://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic?alt=json-in-script&callback=jQuery18204341156887821853_1416248123466&start-min=2014-10-26T00%3A00%3A00Z&start-max=2014-12-07T00%3A00%3A00Z&singleevents=true&max-results=9999&_=1416248372436



来源:https://stackoverflow.com/questions/26980924/google-us-holidays-calendar-feed-forbidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!