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