0
我创建的web应用程序,将与谷歌日历工作。 我使用Guzzle进行http请求。 我成功授权并获得令牌。 我尝试在某些日历中添加事件时遇到了一些麻烦。请求谷歌日历api
$url = 'https://www.googleapis.com/calendar/v3/calendars/'. $calendar_id .'/events';
$client = new Guzzle\Http\Client();
$data = json_encode(array(
"end" => array("date" => "2015-04-02"),
"start" => array("date" => "2015-04-01"),
"summary" => "test3"
));
$request = $client->post($url, [], $data);
$request->setHeader('Authorization', $token_type . ' ' . $token);
$response = $request->send();
echo $response->getBody();
的响应是
Client error response [status code] 400 [reason phrase] Bad Request [url] https://www.googleapis.com/calendar/v3/calendars/some_calendar/events
请给我解释一下什么是错的?
非常感谢!
望着狂饮源代码'POST'只需要两个参数。看起来你应该使用'$ client-> post($ url,['json'=> $ data]);'而不使用'json_encode'。那样有用吗? – abraham 2015-04-02 03:28:56