The primarly code was found on: http://www.checkurl.info
How to use:
Regards
Adrian
P.S. Any NP$ is welcome
P.P.S. Any problem write me on PM or here in forum
Code:
function Alexa($domain) {
//define vars
$return = 0;
$serviceURL = 'http://awis.amazonaws.com/onca/xml';
$service = "AlexaWebInfoService";
$operation = "UrlInfo";
$timestamp = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()); // Timestamp format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
$signature = '';
$secretAccessKey = 'YOUR SECRET KEY';
$signature = urlencode(calculate_RFC2104HMAC($service.$operation.$timestamp,$secretAccessKey));
$timestamp = urlencode($timestamp);
// construct the query
$q = '?Service='.$service
.'&AWSAccessKeyId=YOUR PUBLIC KEY'
.'&Operation='.$operation
.'&ResponseGroup=Rank'
.'&Url=www.'.$domain
.'&Timestamp='.$timestamp
.'&Signature='.$signature;
// get the xml results
$fetchURL = $serviceURL.$q;
if(!$xml = @file_get_contents($fetchURL)) {
$file = @file($fetchURL);
$xml = implode("", $file);
}
// echo $xml;
// if the result was invalid, meaning API key expired
if(strstr('<IsValid>False</IsValid>', $xml)) {
$xml = '<Rank>-1</Rank>';
}
// find the rank
preg_match('/\<Rank\>(\d+)\<\/Rank\>/', $xml, $result);
$return = $result[1];
// return the results
return "$return";
}
function calculate_RFC2104HMAC ($data, $key) {
return base64_encode (
pack("H*", sha1((str_pad($key, 64, chr(0x00))
^(str_repeat(chr(0x5c), 64))) .
pack("H*", sha1((str_pad($key, 64, chr(0x00))
^(str_repeat(chr(0x36), 64))) . $data))))
);
}
Code:
$apr=Alexa("namepros.com");
echo "Alexa Rank for namepros.com is: ".$apr."<br>";
Regards
Adrian
P.S. Any NP$ is welcome
P.P.S. Any problem write me on PM or here in forum






