[英]Pagination in google analytics report
在這里,我正在獲取下一個和上一個URL,但是當嘗試使用該URL訪問下一頁時,由於
錯誤:{“錯誤”:{“錯誤”:[{“域”:“全局”,“原因”:“必需”,“消息”:“需要登錄”,“ locationType”:“標題”,“位置” :“授權”}],“代碼”:401,“消息”:“需要登錄”}}
public function getPaginationInfo(&$results) {
$client = new Google_Client();
if( isset( $_SESSION['access_token'] ) ){
$client->setAccessToken($_SESSION['access_token']);
}
// Create an authorized analytics service object.
$analytics = new Google_Service_Analytics($client);
// Get the first view (profile) id for the authorized user.
$profile = $this->getFirstProfileId($analytics);
// Get the results from the Core Reporting API and print the results.
$this->results = $this->getResults($analytics, $profile);
var_dump( $this->results );
$html = <<<HTML
<pre>
Items per page = {$this->results->getItemsPerPage()}
Total results = {$this->results->getTotalResults()}
Previous Link = {$this->results->getPreviousLink()}
Next Link = {$this->results->getNextLink()}
</pre>
HTML;
print $html;
}
我也想知道當前的頁碼,那有什么功能嗎?
您需要添加accesss_token參數: &access_token=ya29.AKDF.....
您應該能夠從授權的客戶端對象中獲取它:
$token = $client->getAccessToken();
然后將此令牌附加到您的下一頁鏈接。
$this->results->getPreviousLink() . "&access_token=" . $token
然后,應該對鏈接進行身份驗證。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.