Goog日。當我嘗試通過API來獲取自定義維度,我得到了錯誤通過Google Analytics(分析)API獲取自定義維度時的問題
異常 'Google_Service_Exception' 有消息 '錯誤調用get https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/customDimensions: (400)無法通過查詢〜所有ID webPropertyId'
我的代碼
$service_account_name = '<Service Email>@developer.gserviceaccount.com';
$key_file_location = '<keyName>.p12';
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array(Google_Service_Analytics::ANALYTICS),
$key,
'notasecret',
'http://oauth.net/grant_type/jwt/1.0/bearer',
'<My email>'
);
$client->getAuth()->setAssertionCredentials($cred);
$service = new Google_Service_Analytics($client);
$result = $service->management_customDimensions->listManagementCustomDimensions('~all', '~all');
print_r($result);
用於獲取目標的類似代碼正常
$service_account_name = '<Service Email>@developer.gserviceaccount.com';
$key_file_location = '<keyName>.p12';
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array(Google_Service_Analytics::ANALYTICS),
$key,
'notasecret',
'http://oauth.net/grant_type/jwt/1.0/bearer',
'<My email>'
);
$client->getAuth()->setAssertionCredentials($cred);
$service = new Google_Service_Analytics($client);
$result = $service->management_profiles->listManagementProfiles('~all', '~all');
print_r($result);
這兩種方法listManagementProfiles和listManagementProfiles都獲取參數$ accountId和$ webPropertyId。 有人可以幫助,爲什麼我得到錯誤,同時通過API獲取自定義維度?
的註釋爲他人調用'listManagementProfiles'與'〜all'參數,如果您想要所有帳戶,屬性和視圖的列表,請致電[帳戶摘要](https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries/list)端點。 – Matt