Jump to content

Module: Google Calendar Loader


ryan

Recommended Posts

  • 2 weeks later...

For anyone having trouble  with the break/continue error:

It's related to these lines in the MarkupLoadGCal.module file

// filter out events that started before the requested time 
// these will be multi-day events that span into the requested time
if($from && $a->from < $from) continue; 

and for the time being I've gotten around it by commenting out that line and displaying all events from a week in the past on:

$fromDate = date('Y-m-d', strtotime("-1 week"));

This was my desired behaviour anyway so it should not cause any problems, so long as events are not longer than a week. 

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...
  • 3 months later...

Google Calendar API v2 was depreciated on November 17, 2014. I can't seem get the "full" xml feed anymore, which is required for the module to work as Ryan indicates in the first post, and I'm guessing it's because an API Key is now required.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Ryan wrote this on github:

I'm aware of this, but unfortunately don't have the bandwidth to re-build this module at present. The new API is a completely different animal from the old, so there's no quick fix here. I hope to get to this eventually, but it could be a couple months before I can get into it due to other scheduled obligations. As a result, I am looking for anyone that might have more bandwidth than me in the short term that might be interested in taking over this module. Though if we can't find anybody, then I will still plan to update it as soon as there's time to do so.

https://github.com/ryancramerdesign/MarkupLoadGCal/issues/5

  • Like 1
Link to comment
Share on other sites

This API withdrawal just hit my latest project pretty badly and, consequently, I've switched over to fullcalendar as I find that the big players like Amazon and Google deprecate some of their APIs frequently and it makes those services a pain to work with.

For what it's worth, the latest version of fullcalendar does have google calendar API v3 integration but I've gone down the route of using the fullcalendar event handlers and a little ajax for creating/reading/updating/deleting events and storing them as pages in PW; so now my calendar-based projects can work without the need for a connection to google. I hope to get round to releasing this as a stand-alone module eventually.

  • Like 6
Link to comment
Share on other sites

Been using fullcalendar myself in a project in November so can recommend that but obviously some work required to store events in Processwire and output them to fullcalendar until a module exists.

It did feel good not to rely on another service for the calebdar data though!

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

I found out this week that Google still has the "basic" calendar feed open. We know the "full" calendar feed has been gone since November, and I hadn't read anything about any of them still being open. So I have no idea if the basic one was re-opened, or if it's always been open, but it's there and fully accessible. Maybe this is common knowledge, but it's news to me–I found out about it just experimenting with Google's URLs. It's a much bigger pain to pull the data from than the "full" one since most of the data is not structured, so it has to be parsed out with regular expressions. But I went ahead and updated this module to support the basic feed, as it has all the data that we need in it. It's now ready to use in the latest update (v2.0.0).

It looks like the "basic" feed also accepts all of our date and keyword queries too, which is great. As far as I can tell, it returns this module to a fully functional state with all features working once again. I'm guessing that because we have to parse the data with regex's that much of it may not translate to Google calendars in other languages than English, so that's something to be aware of. But if anyone comes across any examples I can always see what might be necessary to add support. 

  • Like 2
Link to comment
Share on other sites

There's also another way of pulling calendar information from Google - but you have to have an API key to do so.  I have a non-Processwire site (still on the task list of one to convert) where I pull Google Calendar data. This is a snippet of what I recently ended up with once I realized that the full calendar feed was no longer working.

// GET NEXT FOUR UPCOMING EVENTS
// maxResults = 4
// timeMin = current timestamp in ISO8601 format

$url = 'https://www.googleapis.com/calendar/v3/calendars/[EMAILADDRESS]/events/?key=[APIKEY]&timeMin=' . date('Y-m-d\TH:i:s\Z') . '&maxResults=4&singleEvents=true&timeZone=Los_Angeles&orderBy=startTime';

$calendar = json_decode(file_get_contents($url), TRUE);
$events = array();
foreach ($calendar['items'] as $item) {

    if (array_key_exists('dateTime', $item['start'])) { // has a specific beginning time
	$events[] = array(
	  'title'=>  $item['summary'],
	  'start'=>  strtotime(substr($item['start']['dateTime'], 0, -6)),
	  'end'=>  strtotime(substr($item['end']['dateTime'], 0, -6)),
	);
    } else { // an all-day event with no specific beginning time
	$events[] = array(
	  'title'=>  $item['summary'],
	  'start'=>  strtotime($item['start']['date']),
	  'end'=>  strtotime($item['end']['date']),
	);
    }
}

return $events;

Who knows if Google will eventually close off the basic feed or not, so at least there's a bit of an alternative approach here if they do that.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...