I am using Alexa API in PHP to get ranking of websites. The API was working pretty fine few days ago but yesterday it suddenly stops working. The API seems giving me NO wanted output but only error.
My work is in context to the post Fetching Alexa data. I have some doubt that we might have run out of given limit (25K/day but not sure; I heard it somewhere else). But I am also suspecting that we can not consume such huge number of requests.
The API code is working on my localhost without any issue. So I guess Amazon/Alexa might have blocked my live server IP. Can they do? What are other alternatives to use Alexa API? Worst thing here is that there is no docs available on net at the moment. How can I make it working again on my live server?
My API code is given below:
// Get Alexa Data
$url = "http://data.alexa.com/data?cli=10&dat=snbamz&url=" . $domain;
$response = simplexml_load_file($url);
// If you don't know when/where <POPULARITY> may be, you should use XPath to find it
//$popularity = $response->xpath("//SD/POPULARITY")[0];
// It will return a list of SimpleXMLElements,
$response_array = $response->xpath("//SD[POPULARITY]")[0];
$alexa = json_decode(json_encode($response_array), true);
echo "<pre>";
print_r($alexa);
echo "</pre>";
$global_rank = isset($alexa['POPULARITY']['@attributes']['TEXT']) ? number_format($alexa['POPULARITY']['@attributes']['TEXT']) : "N/A";
$country_rank = isset($alexa['COUNTRY']['@attributes']['RANK']) ? number_format($alexa['COUNTRY']['@attributes']['RANK']) : "N/A";
$country = isset($alexa['COUNTRY']['@attributes']['NAME']) ? $alexa['COUNTRY']['@attributes']['NAME'] : "N/A";
I am getting only "N/A" along with Notice: Undefined offset: 0 in...