I've got a REST call to my Google calendar that works out fine on my old website (www.gmbc.org/events.php), but when the identical call is made from a codeigniter controller, the timeMin / timeMax options cause it to throw a 400 at me (remove them, and the call successfully retrieves the whole calendar from 2012):
$st_date = date(DateTime::ATOM);
$end_date = date(DateTime::ATOM, time()+(31 * 24 * 60 * 60));
$call_url = 'https://www.googleapis.com/calendar/v3/calendars/calendar%40gmbc.org/events?timeMin='.$st_date.'&timeMax='.$end_date.'&singleEvents=true&orderBy=startTime&key=[mykeythatworksjustfine]';
$events_call = $this->curl_get($call_url);
echoing $call_url confirms it's being created identically, and print_r-ing the result confirms it's reaching google:
stdClass Object (
[error] => stdClass Object (
[errors] => Array (
[0] => stdClass Object (
[domain] => global [reason] => badRequest [message] => Bad Request )
)
[code] => 400 [message] => Bad Request
)
)
...what could possibly be going on? Does codeigniter interfere with the curl call?
I am able to successfully retrieve events from this calendar with TimeMin and TimeMax set using the API explorer: https://developers.google.com/apis-explorer/#p/calendar/v3/calendar.events.list?calendarId=calendar%2540gmbc.org&timeMax=2014-11-30T00%253A00%253A00Z&timeMin=2014-10-01T00%253A00%253A00Z&_h=2&
The query it's sending is: GET https://www.googleapis.com/calendar/v3/calendars/calendar%40gmbc.org/events?timeMax=2014-11-30T00%3A00%3A00Z&timeMin=2014-10-01T00%3A00%3A00Z&key={YOUR_API_KEY}
Try making sure the query you are sending from PHP ends up the same.