我正在尝试access token
使用此代码但没有取得任何成功。我检查了每一个 curl 操作,一切都很好。但仍然无法获得令牌。
$data_string = "code=" . $_REQUEST['code'] . "&client_id=" . $client_id . "&client_secret=" . $client_secret . "&redirect_uri=" . $redirect . "&grant_type=authorization_code";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'https://accounts.google.com/o/oauth2/token');
curl_setopt($ch,CURLOPT_POST,TRUE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-type: application/x-www-form-urlencoded'));
curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string);
$response = curl_exec($ch);
curl_close($ch);
//$data = json_decode($response);
print_r($response);