Showing alexa using HTML code

Status
Not open for further replies.
14 comments
try to follow that exact tutorial, and then post your code with paste bin and then I can help point out your errors if you have any.
 
Alright try to replace your current list of php with

PHP:
<?php
require_once '../class.alexa.php';


  $alexa = new Alexa();
  echo $alexa->getRank("http://www.google.com");
?>

If you upload the class.alexa to the root you must call it up accordingly.

Keep it simple to start and improve as you go.
 
This code is way too simple to understand, so let's use this out.

PHP:
<?php
function alexaRank($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")) {
        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 $str[1];
echo $str[1];
echo "Pankaj";
}
?>

But its printing nothing. See warez-core.com/a.php
 
Just noticed you never called the function. Also you can't have anything after a return statement.

Code:
<?php
function alexaRank($domain){
    $remote_url = '[URL]http://data.alexa.com/data?cli=10&dat=snbamz&url=[/URL]'.trim($domain);
    $search_for = '<POPULARITY URL';
    if ($handle = @fopen($remote_url, "r")) {
        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 $str[1];
}
echo alexaRank('test.com');?>
 
Status
Not open for further replies.
Back
Top