php – Get domain age and alexa rank from javascript-ThrowExceptions

Exception or error:

I want to get Alexa rank in my clientside, but I don’t know the proper way to do it. while running localhost it working, when using on my hosted website its not.

PHP code:

<?php
$xml = simplexml_load_file('http://data.alexa.com/data?cli=10&dat=snbamz&url=linkedin.com');
$rank=isset($xml->SD[1]->POPULARITY)?$xml->SD[1]->POPULARITY->attributes()->TEXT:0;
$web=(string)$xml->SD[0]->attributes()->HOST;
echo $web." has Alexa Rank ".$rank;
?>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *