问题
I am trying to add a Google calendar through the add by URL method. I receive a generic error of "Failed to add imported calendar at 'my URL' for 'my username' " from Google calendar. The URL I'm adding to Google calls a Restful service that sends back a .ics file. I am able to validate my URL here: http://severinghaus.org/projects/icv/ and here: http://icalvalid.cloudapp.net/ What is it that Google calendar is expecting to receive that I am missing?
These are the contents of the .ics file I am returning:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Bryan G LLC//Bryan G Calendar 2014.4.30//EN
X-WR-CALNAME:Bryang Calendar
X-WR-TIMEZONE:America/New_York
BEGIN:VTIMEZONE
TZID:America/New_York
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20140505T131700Z
DTSTART;TZID=America/New_York:20140725T084500
DURATION:PT2H
UID:1248@bryang.net
SUMMARY:Burns JRSR High School FH C V Home Rocky Mountain High School
LOCATION:Home
DESCRIPTION:
END:VEVENT
END:VCALENDAR
回答1:
Same issue here. I had a very long URL with lots of encoded data, but I'm certain the URL was 100% following the spec. In the server logs I could see that Google wasn't even trying to load the feed, it just rejected it with a generic error. Unfortunately, like MSIE6 was a while ago, google is too big to ignore and they can get away with anything, so now it's my issue to solve.
I tried the following:
- adding .ical to the URL;
- encoding the URL-encoded data as hexadecimals instead;
- adding a random parameter to avoid caching;
- using a newly created subdomain instead of subfolder;
and maybe more that I don't remember. All useless.
Finally I used the new subdomain and wrote all the encoded data into a file, like user7subscriptions.txt
. Now the URL looks like this: http://ical.example.net/?id=7. This works. For no apparent reason, a very short URL will just work.
It has nothing to do with the ical contents. The data never changed, it can't be that Google got a bad cache (I would have seen the request that they would have cached, there never was one).
回答2:
Ok, so this is the weirdest. I ran into more or less the same issue: have an ics feed, tried to add it to Google Calendar with "Add by url", got generic error "Failed to add imported calendar".
I searched the web, found a couple of related unresolved questions from some time ago. Lots of people complaining about the unpredictability of this functionality.
Among the things suggested, I tried messing with the headers, including the feed as a file attachment, actually writing a file to disk and give Google Calendar a static link. Nothing worked. At some point I finally noticed that Google Calendar wasn't even trying to fetch the feed, as no hit reached the url, and no log would show on the server.
So I began testing with a request bin and with a local tunnel. Still got nothing. In the end, I opened the browser console to try and have a look at the requests made by the Google Calendar website when you press "add by url" ... and my feed got imported!
I have no logical explanation for that. I wish I had a perfect answer for all Google Calendar "Add By Url" issues, but at this point I can only add my own experience in hope it proves useful to someone else with the same struggle.
Now my feed is built with the excellent Sabre/vObject library. But it doesn't even get validated by any online validators. I tend to think those are outdated and my feed is actually pretty fine. Furthermore, I had no issue importing this same feed in Mac's iCal, and to import its events in Google Calendar with the "Import file" option.
My take on this is that Google Calendar uses "caching" a lot, and that the hardest part is to get your feed in the system. Once it's there, you should be fine. The fact that icalendar feeds only get updated every 8 hours or so is well known and documented. Maybe opening the chrome inspector actually helped. Stranger things have happened.
What I can confirm however, is that most other things don't matter: I don't use file attachment, and the header reads "Content-Type: text/calendar; charset=UTF-8". My feed is not perfect, it has some empty UIDs for example. Also, the server hit that actually made it work was issued at the time I succeeded in importing the feed, so no time factor in play here, and the IP was from Google, so no client side fetching for instance.
来源:https://stackoverflow.com/questions/23473919/google-calendar-add-by-url-requirements