我正在尝试获取已上传到 Google Play
的应用程序的下载次数。
我正在寻找一个 API(或类似的东西),它可以通过用户身份验证为我检索下载次数。我不想要第三方应用程序(如 AppAnnie)。
如果它可以在 PHP 上运行,那就太好了,我发现有一个库,我认为它是我能找到的最接近从 Google 应用程序获取数据的 API。
Google APIs Client Library for PHP
但我找不到任何提及 Google Play
的应用程序。
有没有什么方法可以下载具有身份验证 key 的特定应用程序?
提前致谢!
最佳答案
使用 google-play-scraper获取应用程序信息的库如下:
示例:
$app = $scraper->getApp('com.mojang.minecraftpe');
结果:
array (
'id' => 'com.mojang.minecraftpe',
'url' => 'https://play.google.com/store/apps/details?id=com.mojang.minecraftpe',
'image' => 'https://lh3.googleusercontent.com/30koN0eGl-LHqvUZrCj9HT4qVPQdvN508p2wuhaWUnqKeCp6nrs9QW8v6IVGvGNauA=w300',
'title' => 'Minecraft: Pocket Edition',
'author' => 'Mojang',
'author_link' => 'https://play.google.com/store/apps/developer?id=Mojang',
'categories' => array (
'Arcade',
'Creativity',
),
'price' => '$6.99',
'screenshots' => array (
'https://lh3.googleusercontent.com/VkLE0e0EDuRID6jdTE97cC8BomcDReJtZOem9Jlb14jw9O7ytAGvE-2pLqvoSJ7w3IdK=h310',
'https://lh3.googleusercontent.com/28b1vxJQe916wOaSVB4CmcnDujk8M2SNaCwqtQ4cUS0wYKYn9kCYeqxX0uyI2X-nQv0=h310',
// [...]
),
'description' => 'Our latest free update includes the Nether and all its inhabitants[...]',
'description_html' => 'Our latest free update includes the Nether and all its inhabitants[...]',
'rating' => 4.4726405143737793,
'votes' => 1136962,
'last_updated' => 'October 22, 2015',
'size' => 'Varies with device',
'downloads' => '10,000,000 - 50,000,000',
'version' => 'Varies with device',
'supported_os' => 'Varies with device',
'content_rating' => 'Everyone 10+',
'whatsnew' => 'Build, explore and survive on the go with Minecraft: Pocket Edition[...]',
'video_link' => 'https://www.youtube.com/embed/D2Z9oKTzzrM?ps=play&vq=large&rel=0&autohide=1&showinfo=0&autoplay=1',
'video_image' => 'https://i.ytimg.com/vi/D2Z9oKTzzrM/hqdefault.jpg',
)
编辑:轻松获取下载计数如下:
echo $app['downloads']; // Outputs: '10,000,000 - 50,000,000'
或者如果你想要左边的值:
$matches = null;
$returnValue = preg_match('/.*(?= -)/', '10,000,000 - 50,000,000', $matches);
echo $matches[0]; // Outputs: '10,000,000'
或者如果你想要正确的值:
$matches = null;
$returnValue = preg_match('/(?<=- ).*/', '10,000,000 - 50,000,000', $matches);
echo $matches[0]; // Outputs: '50,000,000'
然后使用以下方法轻松地将其转换为整数:
$count = null;
$returnValue = (int)preg_replace('/,/', '', $matches[0], -1, $count);
echo $returnValue; // Outputs: 10000000 or 50000000
关于php - 是否可以从 Google Play 获取应用程序的下载次数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42350351/