Проблема с обновлением библиотеки PHP API Google Client - PullRequest
0 голосов
/ 22 января 2019

Мне нужно обновить пакет google/apiclient 1.0.*@dev до ^2.2.

У меня был этот код в версии 1.0:

$this->_client = new Google_Client();
$this->_client->setAssertionCredentials(new Google_Auth_AssertionCredentials(
    '__ACCOUNT__',
    ["https://www.googleapis.com/auth/analytics.readonly"],
    file_get_contents('__PATH_TO_KEY__'))
);

$this->_client->setClientId('__CLIENT_ID__');
$this->_analytics = new Google_Service_Analytics($this->_client);

Как заменить этот код наверсия 2.2?

1 Ответ

0 голосов
/ 22 января 2019

Следующий код взят из моего примера проекта Oauth2Authentication.php

$client = new Google_Client();
$client->setAccessType("offline");        // offline access.  Will result in a refresh token
$client->setIncludeGrantedScopes(true);   // incremental auth
$client->setAuthConfig(__DIR__ . '/client_secrets.json');
$client->addScope("https://www.googleapis.com/auth/analytics.readonly");
$client->setRedirectUri(getRedirectUri());

getOauth2Client()
$service = new Google_Service_Analytics($client); 
...