【发布时间】: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