【问题标题】:PHP Gmail API doesn't fetch emailsPHP Gmail API 不获取电子邮件
【发布时间】:2014-08-19 19:55:46
【问题描述】:

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

【问题讨论】:

    标签: php oauth-2.0 google-oauth google-api-php-client gmail-api


    【解决方案1】:

    我不认为 atom 提要是 API 的定义范围。 documentation 只定义了基本的:Modify、ReadOnly 和 Compose 范围。 Atom Feed 只显示未读消息,即使这样也只显示消息的snippets

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 2014-10-30
      • 1970-01-01
      • 2014-09-07
      • 2015-12-15
      • 2020-09-02
      相关资源
      最近更新 更多