簡體   English   中英

PHP Google API客戶端更新庫問題

[英]PHP Google API Client updating library problem

我必須將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版的此代碼?

以下代碼來自我的示例項目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); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM