Google アナリティクス API を使用して、プロファイルの 1 つのレポート データを取得しています。レポートの行数が 1000 を超える場合、応答には 1,000 の結果と、nextPage
データの次のページの URL を含む というパラメータが含まれます。データを取得するためにこの URL を実際に使用する方法がわかりません。次のページのデータを実際に取得するために使用する API メソッド。これが私のコードです:
$client = new Google_Client();
$client->setApplicationName('Google Analytics'); // name of your app
// set assertion credentials
$client->setAssertionCredentials(
new Google_Auth_AssertionCredentials(
GOOGLE_ANALYTICS_SERVICE_EMAIL, // email you added to GA
array('https://www.googleapis.com/auth/analytics.readonly'),
file_get_contents(storage_path().'/keys/privatekey.p12') // keyfile you downloaded
));
$client->setClientId(GOOGLE_ANALYTICS_CLIENT_ID); // from API console
$service = new Google_Service_Analytics($client);
$result = $service->data_ga->get(
'ga:'.DEFAULT_VIEW_ID,
'2014-09-01',
'2015-01-26',
'ga:uniquePageViews',
array(
'dimensions'=>'ga:dimension1',
'filters'=>'ga:dimension3==product'
)
);
print_r($result);
この結果はGoogle_Service_Analytics_GaData
、1000 行に加えて次のデータを含むオブジェクトです。
[nextLink] => https://www.googleapis.com/analytics/v3/data/ga?ids=ga:86454007&dimensions=ga:dimension1&metrics=ga:uniquePageViews&filters=ga:dimension3%3D%3Dproduct&start-date=2014-09-01&end-date=2015-01-26&start-index=1001&max-results=1000
nextLink
これを使用して次のページのデータを取得するにはどうすればよいですか? これには何らかのメカニズムが Google SDK に組み込まれているはずですよね?