异常'Google_Service_Exception',消息'错误调用GET https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/customDimensions: (400)无法通过~all for 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获取自定义尺寸时出错?
答案 0 :(得分:1)
查看文档agg <- aggregate(x$val1, list(id11 = x$id1, id2= x$id2), mean)
names(agg)[3] <- c("val1") # Rename the column
是specifically mentioned as valid parameter value for listManagementProfiles:
要检索的视图(配置文件)的帐户ID。可以是一个 特定帐户ID或'~all',表示所有帐户 用户有权访问。
但不适用于listManagementCustomDimensions,这里只是说
要检索的自定义维度的帐户ID。
(属性ID相同)。因此,您的问题完全是错误消息所说的,在查询自定义维度时无法使用truncate table Patient
。
因此,似乎要列出所有自定义维度,您必须遍历属性ID列表(由properties/list方法返回)而不是使用"~all"