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