Pages

How to Fetch the Alexa Rank of the Website with PHP Script

Alexa rank is a most important factor of any particular website. It is a frequency of visits on a website. Lower Alexa rank means higher traffic to that website. Its ranking system is based on information collected from users who have installed its toolbar.

Fetch the Alexa Rank of the Website

Here, You will find, how to fetch the Alexa rank of a particular website with suing a simple PHP script. To get the Alexa rank, we have to pass the URL of a website to getAlexaRank() function.
The function will return the rank which can further be stored inside a variable or in the database, or can be displayed on screen.

//PHP Script to Fetch Alexa Rank

function getAlexaRank($url){
$xml = simplexml_load_file('http://data.alexa.com/data?cli=10&dat=snbamz&url='.$url);
$rank=isset($xml->SD[1]->POPULARITY)?$xml->SD[1]->POPULARITY->attributes()->TEXT:0;
return $rank;
}
echo getAlexaRank('http://coffeecupweb.com');

ethan

Phasellus facilisis convallis metus, ut imperdiet augue auctor nec. Duis at velit id augue lobortis porta. Sed varius, enim accumsan aliquam tincidunt, tortor urna vulputate quam, eget finibus urna est in augue.

No comments:

Post a Comment