/* $id = 9 digit number You can find the App ID on the URL to the AppStore, for example awesomefactsapp.com link is the following: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=309526865&mt=8 So in this case, the $id would be 309526865. */ function AppStore($id) { $result = file_get_contents('http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?id=25204&popId=30', false, stream_context_create(json_decode('{"http":{"method":"GET","header":"X-Apple-Store-Front: 143441-1","user_agent":"iTunes\/4.2 (Macintosh; U; PPC Mac OS X 10.2)"}}', true))); if (preg_match_all('~>(\d+)\.<.*?viewSoftware\?id=(\d+)&.*?draggingName="(.*?)"~s', $result, $matches) > 0) { $result = array_search($id, $matches[2]); if ($result !== false) { $result++; echo '<h2>"' . $matches[3][$result - 1] . '" is ranked #' . $result . ' overall in the US.</h2>'; } return $result; } return false; } ?> |
Usage example:
var_dump(AppStore(309526865))); // returns the rank or false if the App is not in the Top 100. ?> |
1 comment:
when i am executing code its nothing prints,
i have itunes installed in my machine.
Post a Comment