我的Google日历上有一个REST调用,在我的旧网站(www.gmbc.org/events.php)上运行正常,但是当从一个codeigniter控制器发出相同的调用时,timeMin / timeMax选项导致它向我抛出400(删除它们,并且调用成功从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);
回显$ call_url确认它的创建方式相同,print_r-ing结果确认它已到达google:
stdClass Object (
[error] => stdClass Object (
[errors] => Array (
[0] => stdClass Object (
[domain] => global [reason] => badRequest [message] => Bad Request )
)
[code] => 400 [message] => Bad Request
)
)
......可能会发生什么? codeigniter会干扰卷曲调用吗?
答案 0 :(得分:0)
我可以使用API资源管理器设置TimeMin和TimeMax,从此日历成功检索事件: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&
它发送的查询是: 获取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}
尝试确保您从PHP发送的查询结果相同。