2
我在google api url中有一段代碼,現在我該如何將它轉換爲訪問令牌? 我用捲曲,但它不工作。 任何連擊和簡單的想法,我必須在codeigniter中使用。 和那個authorization_code是什麼?Google api + php + codeigniter + curl
<?php
$field='code='.$_REQUEST['code'].'&client_id=clirnt-id
&client_secret=client-secret
&redirect_uri=http: // localost/googleapi/curlreq.php
&grant_type=authorization_code';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.googleapis.com/oauth2/v3/token");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$field);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/x-www-form-urlencoded'));
$server_output = curl_exec ($ch);
echo 'end';
echo '<br/>';
//echo $server_output;
print_r($server_output);
curl_close ($ch);
?>
嘗試https://github.com/google/google-api-php-client –
我通過Hybrid Auth獲得此信息。它給所有的apis雅虎,fb,g +,twitter everthing ..它真的很好 –