If all you are trying to do is show Alexa rank or whatever they call it, there is a link on the Alexa site where you get the code. Look around. ---------- I went to Alexa and had a look around myself. They have a section called webmaster tools. The needed link there is not currently working for me. Shannon
BOGUS! Try this... http://www.hot-php-scripts.com/php-script/Google_Page_Rank_and_Alexa_checking_Script.htm
Nice untruths... function getAlexaRank( $url ) { preg_match( '#<POPULARITY URL="(.*?)" TEXT="([0-9]+){1,}"/>#si', file_get_contents('http://data.alexa.com/data?cli=10&dat=s&url=' . $url), $p ); return ( $p[2] ) ? number_format( intval($p[2]) ):0; } $domains = array( 'google.com', 'danltn.com', 'msn.com', 'live.com' ); foreach ( $domains as $domain ) echo $domain, ' - ', getAlexaRank( $domain ), '<br />', PHP_EOL; PHP: Works just fine for me.
Is this code working? I want to show alexa ranking of multiple sites on my blog, will this code work? does anybody else have some better code?
<?php function Alexa($domain) { $remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim($domain); $search_for = '<POPULARITY URL'; if ($handle = @fopen($remote_url, "r")) { $part = null; while (!feof($handle)) { $part .= fread($handle, 100); $pos = strpos($part, $search_for); if ($pos === false) continue; else break; } $part .= fread($handle, 100); fclose($handle); } $str = explode($search_for, $part); $str = array_shift(explode('"/>', $str[1])); $str = explode('TEXT="', $str); return number_format($str[1]); } echo "Alexa ranking: " . Alexa("http://www.digitalpoint.com"); //Output: Alexa ranking: 186 ?> PHP: Function above should do what you need.
<?php $url = ‘bytechip.com’; $new_url = ‘http://www.alexa.com/siteinfo/’.$url; $contents=file_get_contents($new_url); /* This will find the Global Alexa Rank */ $start = strpos($contents, “<div class=\â€data up\â€>â€) +119; $stop= strpos($contents,â€<div class=\â€label\â€>Alexa Traffic Rankâ€); $result = substr($contents,$start,$stop-$start); echo “Global Alexa Rank for “.$url.†= “.$result; ?> Code (markup): For more information : Check out http://www.bytechip.com/2010/04/get-alexa-rank-using-php/