2013-04-29 92 views

回答

2

如果您使用Google APIs Client Library for PHP,這可能是最容易的。

$client = new Google_Client(); 
$client->setApplicationName(APPLICATION_NAME); 
$client->setClientId(CLIENT_ID); 
$client->setClientSecret(CLIENT_SECRET); 

然後,當你擁有的授權代碼,您可以撥打:

$client->authenticate($code); 
$token = json_decode($client->getAccessToken()); 
access_token = $token->access_token; 

然後,您可以使用訪問令牌請求或使​​用客戶端庫來訪問各種谷歌的API(這是很容易) 。

另請參閱https://developers.google.com/+/quickstart/phphttps://github.com/googleplus/gplus-quickstart-php/以獲取流程的完整示例。

+0

嗨Scarygami感謝您的答案。我陷入了http://stackoverflow.com/questions/16276513/how-to-create-an-anti-request-forgery-state-token-in-google-server邊註冊/ 16277569#16277569.Plz給我的幫助 – user2330998 2013-04-29 13:39:50

相關問題