Categories

Archives

Syndication


Alexa ranking script

15
Sep
Posted in PHP, Programming

There are plenty of people out there searching for a script to get the alexa ranking for a site. Last time I looked I didn’t even find a free function to get the data, just some expensive solutions.

So anyway, here’s a PHP coded function we have made that collects the alexa-data with the SimpleXML function. It’s very easily coded so everyone should understand what it does. However, since it uses the SimpleXML function, it can only be used if you run PHP5. That’s a requirement.

Please give us some credit if you use the function. A comment or anything will work!

1
2
3
4
5
6
7
8
9
10
<?php
 
function getalexa($url){
// cdsrc.com
$request_url = "http://data.alexa.com/data?cli=10&dat=snbamz&url=".$url;
$xml = simplexml_load_file($request_url) or die("feed not loading");
return $xml->SD->POPULARITY['TEXT'];
}
 
?>

And here’s a little description of how to use it:

11
12
13
14
<?php
echo getalexa("http://cdsrc.com");
// This would print the alexaranking of cdsrc.com
?>

Simple huh?

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Technorati
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Furl
  • Netscape
  • De.lirio.us
5:02 am on November 23rd, 2007
dsf

great help, thanks.
you can reach me at latent_tm@yahoo.com

12:53 pm on February 18th, 2008
Geo

Thanks for your code…Its really helpful for every one around the world..

8:50 am on February 19th, 2008
Hjalle

Thanks for the positive response:) I hope it helps some lost souls out there:)

9:00 pm on April 6th, 2008
Alex

Wow your like a Php god! you wouldn’t believe how long I’ve spent trying to find out how to do this and you whip it up in 7 lines of php!

3:27 am on April 17th, 2008
google pagerank

Its really helped me to build my site…thanks

9:00 pm on April 23rd, 2008
Hjalle

Thank you!

It’s always simple when you see the solution!

10:16 am on July 24th, 2008
CristianR

Thanks for this great script. It works flawlessly.

8:52 am on August 14th, 2008
Train

Oh, thanx a lot man, this really helps.

5:06 am on October 6th, 2008
alexa rank

Nice post..really gift to every one

5:21 am on October 6th, 2008
cheap webhosting

keep going…..:)

8:31 am on November 2nd, 2008
Thai Food

Wow , Thanks :)

??????????

Leave us a comment