Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Gmail API没有';无法获取电子邮件_Php_Oauth 2.0_Google Oauth_Google Api Php Client_Gmail Api - Fatal编程技术网

PHP Gmail API没有';无法获取电子邮件

PHP Gmail API没有';无法获取电子邮件,php,oauth-2.0,google-oauth,google-api-php-client,gmail-api,Php,Oauth 2.0,Google Oauth,Google Api Php Client,Gmail Api,我将PHP google api与OAuth2一起使用 令牌过程的所有过程 已成功完成 我使用以下范围: $a_scopes = array( Google_Service_Oauth2::USERINFO_EMAIL, Google_Service_Oauth2::PLUS_ME,

我将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>");
$plus=新的Google\u服务\u plus($this->client);
$person=$plus->people->get('me');
$user=$person->getEmails();
回声(“”);var_dump($user);死亡(“”);

结果是:

数组(1){
[0]=>
对象(谷歌服务加个人邮件)#29(4){
[“类型”]=>
字符串(7)“帐户”
[“值”]=>
字符串(17)
[“modelData”:受保护]=>
数组(0){
}
[“已处理”:受保护]=>
数组(0){
}
}
}

我不认为atom提要是API的定义范围。仅定义基本范围:修改、只读和组合范围。Atom提要只显示未读的消息,即使这样,也只显示消息的内容

要解决您的问题,您需要将您的范围定义为Gmail API定义的范围之一

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) {
          }
   }
}