WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Get the AppStore Ranking for any iPhone App
Categories : PHP, Web Services, Regexps Click here to Update Your Picture
Alix Axel
Date : May 31st 2009
Grade : 2 of 5 (graded 3 times)
Viewed : 5017
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Alix Axel
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

This function returns the overall ranking (in the US AppStore) for any iPhone App.

<?php

/*
$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:
<?php
var_dump
(AppStore(309526865))); // returns the rank or false if the App is not in the Top 100.
?>






grab the result of any calculation you submit to the Google Calculator.
Categories : PHP, Arrays, Web Services, Regexps, Math.
Ping a Server and run a command to fix it if it is down
Categories : PHP, Errors and Logging, Regexps
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email addresses via SMTP and regex.
Categories : Email, Regexps, PHP
How to check if a file is of type gif or jpg?
Categories : PHP, Regexps, Graphics
BBCode Formatting String
Categories : PHP, HTML, Regexps, Arrays
Calculate Body Mass Index
Categories : PHP, Algorithms, Regexps
columned txt file to array()?
Categories : Arrays, Strings, Regexps, PHP
Amazon.com API, CURL-REST Parser. Obtain data about Amazon products (PHP5 +)
Categories : PHP, Ecommerce, XML, Web Services, CURL
String Replacement and speed consideration
Categories : PHP, Strings, Regexps
FormChecker Package - validate any data via classes and patterns.
Categories : PHP, Form Processing, PHP Classes, Regexps
Tag content retrieval from websites with preg_match
Categories : PHP, Regexps, Arrays, HTML and PHP
cPanel Email Accounts Creator
Categories : PHP, PHP Classes, Email, Form Processing, Web Services
Newbie Notes #7 - Ridiculous regex
Categories : PHP, Beginner Guides, Regexps
Extract keywords from a string having words in " " count as one string.
Categories : PHP, Strings, Regexps, Search