Results from the most recent live auction are here .
21 members in the live chat room. Join Chat !
04-07-2006, 10:08 AM
· #1 NamePros Regular
Join Date: Mar 2006
Posts: 394
NP$: 286.68 (
Donate )
PHP4 script to get Alexa Traffic Rankings The primarly code was found on:
http://www.checkurl.info 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.$operatio n.$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))))
);
}
How to use:
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
04-07-2006, 10:42 AM
· #2 Account Closed
Thanks for the script! A pretty good one!
04-08-2006, 05:52 AM
· #3 NamePros Regular
Join Date: Mar 2006
Posts: 394
NP$: 286.68 (
Donate )
I just maked work... The script is not made by me.
Regards
04-08-2006, 04:26 PM
· #4 NamePros Regular
Name: Trevor
Location: Atlanta, GA, USA
Join Date: Feb 2006
What is the secret key?
04-08-2006, 04:35 PM
· #5 while ($awake){ code(); }
Name: Eric
Location: Kentucky
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (
Donate )
04-09-2006, 11:02 AM
· #6 NamePros Regular
Name: Trevor
Location: Atlanta, GA, USA
Join Date: Feb 2006
Guess I'll have to get me one of those.
04-09-2006, 12:51 PM
· #7 A Wealth of Knowledge
Join Date: Aug 2004
Posts: 3,787
NP$: 2800.20 (
Donate )
If people need a simple solution, you can query:
Originally Posted by query
For those of you who want the rank without having to worry about any code or the bulky alexa site.
-Steve
04-09-2006, 10:59 PM
· #8 Account Closed
Originally Posted by stscac If people need a simple solution, you can query:
http://www.stscac.com/dev/alexa/?url=x
For those of you who want the rank without having to worry about any code or the bulky alexa site.
-Steve
That's cool you set this up. Newbie developers could use file_get_contents with that URL if they wanted a checker or something. Here's an example for PHP-illiterate folks of how to use this in their scripts.
<?
if (isset($_POST['submit'])) {
$str = file_get_contents("http://www.stscac.com/dev/alexa/?url=".$_POST['url']);
$str = trim($str);
echo "Rating for ".$_POST['url']." is ".$str;
}
else
{
?>
<form name="alexarate" method="post" action="<?=$_SERVER['PHP_SELF']; ?>">
Get Alexa Rating For:
<input type="text" name="url" value="http://"> <input type="submit" name="submit" value="Get Rating!">
</form>
<?
}
?>
04-09-2006, 11:03 PM
· #9 www.1weblord.com
Name: William R. Nabaza - williamrnabaza.com
Location: Philippines - www.Nabaza.com
Join Date: Dec 2005
Posts: 21,398
NP$: 21635.83 (
Donate )
there are also versions that doesn't require AWS developer's key
04-09-2006, 11:05 PM
· #10 Account Closed
Originally Posted by weblord there are also versions that doesn't require AWS developer's key
I'm sure you can develop your own API that communicates with the Alexa site directly. I might script up something for the users at NP when I'm not so tired
04-09-2006, 11:49 PM
· #11 while ($awake){ code(); }
Name: Eric
Location: Kentucky
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (
Donate )
Originally Posted by weblord there are also versions that doesn't require AWS developer's key
Yep
04-09-2006, 11:51 PM
· #12 Steven
Name: Steven Gibbons
Location: United Kindom
Join Date: Aug 2005
Posts: 1,506
NP$: 40.00 (
Donate )
Thanks for this script, i know you didnt make it but i will give you rep for finding it.
04-10-2006, 10:43 AM
· #13 A Wealth of Knowledge
Join Date: Aug 2004
Posts: 3,787
NP$: 2800.20 (
Donate )
Originally Posted by webbist101
Originally Posted by stscac If people need a simple solution, you can query:
http://www.stscac.com/dev/alexa/?url=x
For those of you who want the rank without having to worry about any code or the bulky alexa site.
-Steve
That's cool you set this up. Newbie developers could use file_get_contents with that URL if they wanted a checker or something. Here's an example for PHP-illiterate folks of how to use this in their scripts.
<?
if (isset($_POST['submit'])) {
$str = file_get_contents("http://www.stscac.com/dev/alexa/?url=".$_POST['url']);
$str = trim($str);
echo "Rating for ".$_POST['url']." is ".$str;
}
else
{
?>
<form name="alexarate" method="post" action="<?=$_SERVER['PHP_SELF']; ?>">
Get Alexa Rating For:
<input type="text" name="url" value="http://"> <input type="submit" name="submit" value="Get Rating!">
</form>
<?
}
?>
That's the reason I did it. I remember when I was a rather newbie when it came to web development, and I do remember people helping out and helping me learn different functions through examples.
I figure that some people will not be able to understand the code in the first example, I'll make it a little more bearable for them.
I'm not asking for anything at this time, but just let me know what site you're pulling the data to so I can keep track.
-Steve
04-10-2006, 03:03 PM
· #14 Account Closed
Originally Posted by stscac That's the reason I did it. I remember when I was a rather newbie when it came to web development, and I do remember people helping out and helping me learn different functions through examples.
I figure that some people will not be able to understand the code in the first example, I'll make it a little more bearable for them.
I'm not asking for anything at this time, but just let me know what site you're pulling the data to so I can keep track.
-Steve
Yeah, I can see this becoming a problem. However, I doubt many sites recieving any serious traffic would still use your system, as they would be on a high enough budget to afford developers to do this theirselves.
04-10-2006, 04:20 PM
· #15 A Wealth of Knowledge
Join Date: Aug 2004
Posts: 3,787
NP$: 2800.20 (
Donate )
Originally Posted by webbist101 Yeah, I can see this becoming a problem. However, I doubt many sites recieving any serious traffic would still use your system, as they would be on a high enough budget to afford developers to do this theirselves.
I figured this much. But for those who do use it, just drop me a line.
-Steve
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off