[GET] Bulk DA Checker Using Free Moz API in PHP

Just tried the PHP script in post #10, with a newly created account -- didn't work immediately. Waited 10 minutes and tried again and it works. Moz does say on creating a new API key that it takes about 20 minutes for this key to filter to all their servers.

google.com/|100|96.46

Thanks for the update

As I said it woks on the other places where I put the API which btw is maybe 3 years old.

I've been using this script until now with no problem. The only problem is when you hit the Moz API limitation. Try creating new Moz API just for this script.

Thanks for this free script bro

You're welcome
 
Actually the script is outdated.. basically it's free.. all you need to do is to register for the free moz api and put the script on your cpanel (most of the time it will support php)
 
Try this but got 504 gateway timeout.. o_O
Thanks anyway, i think it's outdated.
 
the most common place to run this script is your regular cpanel hosting.. just copy & paste the script to your hosting, edit the moz key, and you're set

Hi, this thread maybe old, i dont know if you are still available to reply me. Pls, I just uploaded the script to my cpanel using file manager, under the public_html. What next? How do I go about using it? How will I execute it to scrape Tumblr. If there is any link you could point to me, fine. I have searched up to 10 pages online, nothing useful so far.
 
Can you share the code with us??
sure

PHP:
<?php
// Get your access id and secret key here: https://moz.com/products/api/keys
ob_start();
error_reporting(E_ALL ^ E_NOTICE);
set_time_limit(0);

if (!$_POST['linkcheck']) {

   echo "
   <h2>Bulk Domain Authority</h2>
       <form method='POST'>
           <textarea name='linkcheck' cols=100 rows=30></textarea>
           <br>
       <input type=submit>
   </form>";
   exit;
}

$domains = explode("\n",trim($_POST['linkcheck']));
echo "<br><a href='http://moz.com' rel='nofollow'><img src='http://d2eeipcrcdle6.cloudfront.net/brand-guide/logos/moz_blue.png'></a><br>";
ob_flush();
flush();
$totdomain = count($domains);
$result = array();
for ($i=0;$i<$totdomain;$i++){
    $batchedDomains = array();
    for ($j=0;$j<10;$j++){
        $cur = $i + $j;
        $domain =  trim($domains[$cur]);
        if($domain != ""){
            array_push($batchedDomains,$domain);
        }
    }
    array_push($result, get_da($batchedDomains,$i,$filenameda));
    ob_flush();
    flush();
}
show($result);


function get_da($batchedDomains){
    $accessID = "";
    $secretKey = "";
    $expires = time() + 300;
    $stringToSign = $accessID."\n".$expires;
    $binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
    $urlSafeSignature = urlencode(base64_encode($binarySignature));
    $cols = "103616137252";
    $requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
    $encodedDomains = json_encode($batchedDomains);
    $options = array(
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS     => $encodedDomains
       );
    $ch = curl_init($requestUrl);
    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    curl_close( $ch );
    $contents = json_decode($content);
    $counter =0;
    return $contents;
}

function show($content){
    echo "<table border=2>";
    echo "<tr><td style='width: 200px;'>URL</td><td>DA</td><td>PA</td></tr>";
    foreach ($content as $x){
        foreach ($x as $obj){
            $domain = $obj->uu;
            $da     = $obj->pda;
            $pa     = $obj->upa;
            $da     = round($da,2);
            $pa     = round($pa,2);
            echo "<tr><td>$domain</td><td>$da</td><td>$pa</td></tr>";
        }
    }
    echo "</table>";
}
?>
 
sure

PHP:
<?php
// Get your access id and secret key here: https://moz.com/products/api/keys
ob_start();
error_reporting(E_ALL ^ E_NOTICE);
set_time_limit(0);

if (!$_POST['linkcheck']) {

   echo "
   <h2>Bulk Domain Authority</h2>
       <form method='POST'>
           <textarea name='linkcheck' cols=100 rows=30></textarea>
           <br>
       <input type=submit>
   </form>";
   exit;
}

$domains = explode("\n",trim($_POST['linkcheck']));
echo "<br><a href='http://moz.com' rel='nofollow'><img src='http://d2eeipcrcdle6.cloudfront.net/brand-guide/logos/moz_blue.png'></a><br>";
ob_flush();
flush();
$totdomain = count($domains);
$result = array();
for ($i=0;$i<$totdomain;$i++){
    $batchedDomains = array();
    for ($j=0;$j<10;$j++){
        $cur = $i + $j;
        $domain =  trim($domains[$cur]);
        if($domain != ""){
            array_push($batchedDomains,$domain);
        }
    }
    array_push($result, get_da($batchedDomains,$i,$filenameda));
    ob_flush();
    flush();
}
show($result);


function get_da($batchedDomains){
    $accessID = "";
    $secretKey = "";
    $expires = time() + 300;
    $stringToSign = $accessID."\n".$expires;
    $binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
    $urlSafeSignature = urlencode(base64_encode($binarySignature));
    $cols = "103616137252";
    $requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
    $encodedDomains = json_encode($batchedDomains);
    $options = array(
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS     => $encodedDomains
       );
    $ch = curl_init($requestUrl);
    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    curl_close( $ch );
    $contents = json_decode($content);
    $counter =0;
    return $contents;
}

function show($content){
    echo "<table border=2>";
    echo "<tr><td style='width: 200px;'>URL</td><td>DA</td><td>PA</td></tr>";
    foreach ($content as $x){
        foreach ($x as $obj){
            $domain = $obj->uu;
            $da     = $obj->pda;
            $pa     = $obj->upa;
            $da     = round($da,2);
            $pa     = round($pa,2);
            echo "<tr><td>$domain</td><td>$da</td><td>$pa</td></tr>";
        }
    }
    echo "</table>";
}
?>
how many domain search in this script?
any limits?
 
This will help the newbie. And so he is already old.
 
Thanks good idea.. below is the updated version

PHP:
<?php
// Get your access id and secret key here: https://moz.com/products/api/keys
ob_start();
error_reporting(E_ALL ^ E_NOTICE);
set_time_limit(0);

if (!$_POST['linkcheck']) {

   echo "<h2>Bulk Domain Authority</h2><form method='POST'><textarea name='linkcheck' cols=100 rows=30></textarea><br><input type=submit></form>";
   exit;

}

$domains = explode("\n",trim($_POST['linkcheck']));

echo "<br><a href='http://moz.com' rel='nofollow'><img src='http://d2eeipcrcdle6.cloudfront.net/brand-guide/logos/moz_blue.png'></a><br>";
ob_flush(); flush();

$totdomain = count($domains);
for ($i=0;$i<$totdomain;$i=$i+10){
  $batchedDomains = array();
 
  for ($j=0;$j<10;$j++){
    $cur = $i + $j;
    $domain =  trim($domains[$cur]);
    array_push($batchedDomains,$domain);
  }
  get_da($batchedDomains,$i,$filenameda);    ob_flush(); flush();
  sleep(20);
  //exit;
}


function get_da($batchedDomains,$i,$filenameda){

   $accessID = 'mozscape-xxxxxxxxx';
    $secretKey = 'xxxxxxxxxxxxxxxxxx';
 

    $expires = time() + 300;
    //echo "<br>$expires<br>";

    // Put each parameter on a new line.
    $stringToSign = $accessID."\n".$expires;

    // Get the "raw" or binary output of the hmac hash.
    $binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);

    // Base64-encode it and then url-encode that.
    $urlSafeSignature = urlencode(base64_encode($binarySignature));

    // Add up all the bit flags you want returned.
    // Learn more here: https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics
    $cols = "103616137252";

    // Put it all together and you get your request URL.
    $requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;

    // Put your URLS into an array and json_encode them.
    $encodedDomains = json_encode($batchedDomains);

    // Use Curl to send off your request.
    // Send your encoded list of domains through Curl's POSTFIELDS.
    $options = array(
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS     => $encodedDomains
       );

    $ch = curl_init($requestUrl);
    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    curl_close( $ch );

    $contents = json_decode($content);
   $counter =0;
    foreach ($contents as $obj){
        $domain = $obj->uu;
        $da = $obj->pda;    $da = round($da,2);
        $pa = $obj->upa;    $pa = round($pa,2);
        if ($domain == "") $domain = trim($batchedDomains[$counter]);
       if ($domain == "") exit;
        echo "$domain|$da|$pa<br>";
       ob_flush(); flush();
        $counter++;
    }

}

?>

So the output will now be :

URL | DA | PA

How to use it or where to use it please let me know

I don't know how to use it. Any one help me
 
Back
Top