【问题标题】:500 Error in Gmail User Watch API PHPGmail 用户监视 API PHP 中的 500 错误
【发布时间】:2018-11-14 14:09:33
【问题描述】:

我已经在 Cloud Pub/Sub 上设置了主题和订阅,现在我正在尝试在我的 gmail 帐户上设置手表,但由于某种原因,我收到了(500) Backend Error

下面是我使用的代码:

$client = new Google_Client();
$client->setClientId('google_client_id');
$client->setClientSecret('google_client_secret');
$client->setRedirectUri('google_redirect_url');
$client->addScope("https://mail.google.com/");
$client->setAccessType("offline");
$client->setApprovalPrompt('force');
$service = new Google_Service_Gmail($client);
try {
    $watch = new Google_Service_Gmail_WatchRequest($client);
    $watch->setTopicName("projects/project-id/topics/topic-id");
    $messagesResponse = $service->users->watch("me", $watch, array("topicName" => "projects/project-id/topics/topic-id"));
} catch(Exception $e) {
    print_r($e);
}  

我得到以下回应:

大批 ( [userId] => 我 [postBody] => Google_Service_Gmail_WatchRequest 对象 ( [collection_key:protected] => labelIds [labelFilterAction] => [标签ID] => [主题名称] => 项目/项目 ID/主题/主题 ID [internal_gapi_mappings:protected] => 数组 ( ) [modelData:protected] => 数组 ( ) [已处理:受保护] => 数组 ( ) ) [主题名称] => 项目/项目 ID/主题/主题 ID ) Google_Service_Exception 对象 ( [错误:受保护] => 数组 ( [0] => 数组 ( [域] => 全局 [原因] => backendError [消息] => 后端错误 ) ) [retryMap:Google_Service_Exception:private] => 数组 ( [500] => -1 [503] => -1 [rateLimitExceeded] => -1 [userRateLimitExceeded] => -1 ) [消息:受保护] => 调用 POST https://www.googleapis.com/gmail/v1/users/me/watch 时出错:(500) 后端错误

有人可以指导我吗?

【问题讨论】:

    标签: php codeigniter gmail-api php-7


    【解决方案1】:

    我自己解决了。

    任何遇到此问题的人,将发布者权限授予gmail-api-push@system.gserviceaccount.com,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 2014-08-22
      • 2018-03-18
      • 2013-06-28
      • 1970-01-01
      • 2018-02-03
      • 2016-10-15
      • 2017-06-19
      • 1970-01-01
      • 2015-06-27
      相关资源
      最近更新 更多