2

我想从 Google Play 获取任何特定应用的统计信息。身份验证后,我将提供一个 URL,该应用程序的相应统计信息将开始下载。有一个 ZIP 文件夹,其中包含将下载的 CSV 文件。

我所做的是:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$data = array(
    'accountType' => 'GOOGLE',
    'Email'       => my mail address@gmail.com,
    'Passwd'      => my password for this account,
    'source'      => the name of that particular app,
    'service'     => 'writely'
);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$hasil = curl_exec($ch);

这是为了认证。在此之后,我想下载统计信息:

$ch = curl_init("https://play.google.com/apps/publish/statistics/download?package=[my apps name]&sd=[starting date]&ed=[ending date]&dim=[dimensional data]&met=[metrics data]&dev_acc=[developer account ID]");

$header[] = 'Authorization: GoogleLogin auth=' . $hasil;

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);

curl_exec($ch);  
curl_close($ch);

启动脚本后,下载应该会自动开始。

4

0 回答 0