Created
October 10, 2013 09:40
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ?