我将 PHP google api 与 OAuth2 一起使用。
令牌进程的所有进程已成功完成。
我使用范围:
$a_scopes = array(
Google_Service_Oauth2::USERINFO_EMAIL,
Google_Service_Oauth2::PLUS_ME,
'https://mail.google.com/mail/feed/atom'
);
$this->client->setScopes($a_scopes);
我使用代码来检索电子邮件:
$plus = new Google_Service_Plus($this->client);
$person = $plus->people->get('me');
$user = $person->getEmails();
echo("<pre>");var_dump($user);die("</pre>");
结果:
array(1) {
[0]=>
object(Google_Service_Plus_PersonEmails)#29 (4) {
["type"]=>
string(7) "account"
["value"]=>
string(17) <My Email>
["modelData":protected]=>
array(0) {
}
["processed":protected]=>
array(0) {
}
}
}