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 ..它真的很好 –