Skip to content

Instantly share code, notes, and snippets.

@brijrajsingh
Created October 10, 2013 09:40
Show Gist options
  • Save brijrajsingh/6915711 to your computer and use it in GitHub Desktop.
Save brijrajsingh/6915711 to your computer and use it in GitHub Desktop.
a php script to look at the android play store for the given package name, and find out its category.
<?php
class PackageCategory
{
protected static $playurl = 'https://play.google.com/store/apps/details?id=';
public function PackageCategory($packageName) {
$this->packageName = $packageName;
}
public function getPackageCategory()
{
$result = $this->makeRequest(self::$playurl.$this->packageName);
//starting index of category tag
$indexstart = strpos($result,"<span itemprop=\"genre\">");
//ending index of category tag
$indexend = strpos($result,"</span>",$indexstart);
$category = substr($result,$indexstart+23,$indexend - ($indexstart+23));
echo $category;
}
//curl to the play store
/**
* Makes request to AWIS
* @param String $url URL to make request to
* @return String Result of request
*/
protected function makeRequest($url) {
//echo "\nMaking request to:\n$url\n";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
if (count($argv) < 2) {
echo "Usage: $argv[0] PackageName\n";
exit(-1);
}
else {
$packageName = $argv[1];
}
$packageCategory = new PackageCategory($packageName);
$packageCategory->getPackageCategory();
?>
Copy link

ghost commented Apr 27, 2015

It Works Great , But I want to know that is it safe to use? secondly will google block the IP of the site from where i am sending this link ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment