Gmail Push-уведомление PHP ошибка сервера - PullRequest
0 голосов
/ 25 мая 2018

Это мой код для push-уведомления о просмотре gmail

define('SCOPES', implode(' ', array(
        Google_Service_Gmail::MAIL_GOOGLE_COM)
));
$this->client = new Google_Client();
$this->client->setApplicationName(APPLICATION_NAME);
$this->client->setScopes(SCOPES);
$this->client->setAuthConfig(CLIENT_SECRET_PATH);
$this->client->setAccessType('offline');
$this->client->setApprovalPrompt('force');

$credentialsPath = CREDENTIALS_PATH;

if(!file_exists($credentialsPath)){
    redirect('gmail');
}
$accessToken = json_decode(file_get_contents($credentialsPath), true);
$this->token = $accessToken['access_token'];

$this->client->setAccessToken($accessToken);
if ($this->client->isAccessTokenExpired()) {
    $refreshTokenSaved = $this->client->getRefreshToken();
    $this->client->fetchAccessTokenWithRefreshToken($refreshTokenSaved);
    //$client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
    file_put_contents($credentialsPath, json_encode($this->client->getAccessToken()));
}
$service = new Google_Service_Gmail($this->client);
$watchreq = new Google_Service_Gmail_WatchRequest();
$watchreq->setLabelIds(array('INBOX'));
$watchreq->setTopicName('projects/composed-field-201410/topics/wooglobe');
$msg = $service->users->watch('me', $watchreq);

Я получаю эту ошибку Тип: Google_Service_Exception

Сообщение: {"error": {"errors": [{"domain": "global", "reason": "backendError", "message": "Backend Error"}], "code": 500, "message": "Backend Error"}}

Имя файла: D: \ xampp \ htdocs \ viralgreats \ admin \ vendor \ google \ apiclient \ src \ Google \ Http \ REST.php

Номер строки: 118

...