我在这里获取下一个和上一个网址,但在尝试使用网址访问下一个网页时,我收到错误
错误: { “错误”:{ “错误”:[{ “域”: “全局”, “原因”: “需要”, “消息”:“登录 需要 “ ”的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;
}
我也想知道当前的页码,是否有任何功能?
答案 0 :(得分:0)
您需要添加accesss_token参数:&access_token=ya29.AKDF.....
您应该可以从授权的客户端对象中获取它:
$token = $client->getAccessToken();
然后将此令牌附加到您的下一页链接。
$this->results->getPreviousLink() . "&access_token=" . $token
然后应该对链接进行身份验证。