我在我的网络应用程序中使用 google plus API。我可以从 google plus 中拉出所有人
我的代码是
$this->client = new Google_Client();
$this->client->setApplicationName($CI->config->item('application_name', 'googleplus'));
$this->client->setClientId($CI->config->item('client_id', 'googleplus'));
$this->client->setClientSecret($CI->config->item('client_secret', 'googleplus'));
$this->client->setRedirectUri($CI->config->item('redirect_uri', 'googleplus'));
$this->client->setDeveloperKey($CI->config->item('api_key', 'googleplus'));
$this->plus = new Google_PlusService($this->client);
$this->auth2 = new Google_Oauth2Service($this->client);
$peoples = $this->plus->people->listPeople('me','visible');
在这里,我得到了我圈子中所有人的名单。但我不知道人们的电子邮件地址和生日。我怎样才能得到那些?
最佳答案
获得 Google+ ID 列表后,您需要调用 people.get 电话以获取这些用户的 [public] 个人资料数据。在 PHP 中,此调用类似于 $me = $plus->people->get('me');
。对于授权用户,可以使用“我”关键字。否则,您可以使用 Google+ ID 调用电话。
调用后,您可以提取与您相关的属性(完整列表:https://developers.google.com/+/api/latest/people)。
但是,要获取用户的 Google 电子邮件地址,您需要包括 https://www.googleapis.com/auth/userinfo.email
范围以及 plus.login
范围。这意味着您只能获得授权用户的电子邮件地址。
关于php - 如何获取电子邮件地址以及 google plus API 中的人员列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17672709/