但上面链接的文档说有效载荷中的每一行都应该有27个数据字段,而我只能获得7个。而且,我得到的7个本身也没有意义。例如,它提供了一个[
{
"applicationId": "{MYAPPID}",
"date": "2025-01-24",
"acquisitionQuantity": 3,
"purchasePriceUSDAmount": 37.68879931824771,
"purchasePriceLocalAmount": 1689.22,
"purchaseTaxUSDAmount": 2.2483605704174052,
"purchaseTaxLocalAmount": 3.2399999999999998
}
]
,但是不包括本地货币的字段,所以当它告诉我
purchasePriceLocalAmount
...我不知道这是什么意思。是卢比,比索还是dong等?我显然有美元,我只是指出了这一点,因为如果有效负载中包含的字段显然不足以理解数据,这似乎是一个问题。 从他们的文档中,有效负载是什么样子的一个例子:
purchasePriceLocalAmount = 1689.22
我曾经获取这些数据,但这是几年前。我多年来一直在寻找的报告确实只需要知道售出了多少个应用程序,因此我没有注意到数据供稿不再包括所有这些字段。我认为也许他们刚刚更改了提要,但是上面链接的DOC页面在2023年进行了更新,并说我仍然应该在数据有效载荷中获取这些字段。
任何建议?我没有在我的请求中添加任何过滤器,我只是从头到尾请求并抓住整个响应有效载荷。我在下面包含了一些剥离的代码,只是为了让您了解我的提出要求。
[
{
"date": "2019-01-15T01:00:00.0000000Z",
"applicationId": "9WZDNCRFHXHT",
"applicationName": null,
"acquisitionType": "Paid",
"age": null,
"deviceType": "Phone",
"gender": null,
"market": "US",
"osVersion": "Windows 11",
"paymentInstrumentType": null,
"sandboxId": "RETAIL",
"storeClient": "Microsoft Store (client)",
"xboxTitleId": null,
"localCurrencyCode": "USD",
"xboxProductId": null,
"availabilityId": "B42LRTSZ2MCJ",
"skuId": "0010",
"skuDisplayName": null,
"xboxParentProductId": null,
"parentProductName": null,
"productTypeName": "Game",
"purchaseTaxType": "TaxesNotIncluded",
"acquisitionQuantity": 1,
"purchasePriceUSDAmount": 3.08,
"purchasePriceLocalAmount": 3.08,
"purchaseTaxUSDAmount": 0.09,
"purchaseTaxLocalAmount": 0.09
}
]
I找到了一个不同的页面,上面有有关此API的文档:Https://learn.microsoft.com/en-us/windows/uwp/uwp/monetize/get-app-acquicitions
显示了两个不同的样本响应有效载荷,一个是我被剥离的一个,另一个是我所期望的完整有效载荷。
几年前发生了什么变化的事情,为了获得完整的有效载荷,您必须明确将
<?
$token = logintoappstore(...);
$appsales = fetchanalytics($token, $appid, $startdatestring, $enddatestring, 1000, 0);
print_r(['appsales' => $appsales]);
function fetchanalytics(string $token, string $appid, string $startdate, string $enddate, int $pagesize, int $startindex): ?array {
$url = "https://manage.devcenter.microsoft.com/v1.0/my/analytics/acquisitions";
$params = [
'applicationId' => $appid,
'startDate' => $startdate,
'endDate' => $enddate,
'top' => $pagesize,
'skip' => $startindex
];
print "fetching acquisitions from $startdate to $enddate\n";
$data = jsonget($url, $params, $token);
if (isset($data['error'])) {
error_log("unable to fetch acquisitions: ".$data['error']);
return null;
} else {
return $data['Value'];
}
}
function jsonget(string $url, array $params, ?string $authtoken = null): ?array {
// just does intelligent url encoding on the values in the $params array
$queryparamstring = data_url_encode($params);
$url .= '?' . $queryparamstring;
$text = curlget($url, $authtoken);
$data = json_decode($text, true);
if (is_array($data)) {
return $data;
} else {
return null;
}
}
function curlget(string $url, ?string $authtoken = null): string {
$curl = curl($url, $authtoken);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
function curl(string $url, ?string $authtoken = null) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$headers = [
'Content-Type: application/x-www-form-urlencoded',
];
if ($authtoken !== null) {
$headers[] = 'Authorization: Bearer ' . $authtoken;
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
return $curl;
}
命令发送到API。然后,发送到the的每个字段将包含在响应有效载荷中。
因此,如果我将groupby