2013-04-29 95 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

相关问题