Results 1 to 2 of 2

Thread: mozapi php integration

  1. #1
    Join Date
    May 2012
    Thanked 1 Time in 1 Post

    Default mozapi php integration

    Sorry new question, hopefully be the last

    I have been asked if mozapi can be integrated into a php page which know it can be done but I have never done any work before involving api so not sure how to go about it

    the page it needs to go on has the domains in the database and the mozapi info needs to display in correct columns, the client needs the domain authority, trust flow and citation flow if possible to be pulled in from mozapi

    just need pointing in the right direction or a rough start to what the code would look like, I guess I would need to include the db info and query above the api script?

    I found the following coding on Google

    $accessID = "API ID HERE"; // * Add unique Access ID
    $secretKey = "SECRET KEY HERE"; // * Add unique Secret Key
    //Set Expires time in future here 5 minutes.
    $expires = time() + 300;
    // A new linefeed is necessary between your AccessID and Expires.
    $stringToSign = $accessID."\n".$expires;
    // Get the "raw" or binary output of the hmac hash.
    $binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
    // We need to base64-encode it and then url-encode that.
    $urlSafeSignature = urlencode(base64_encode($binarySignature));
    // This is the URL that we want link metrics for.
    $objectURL = $_POST['url'];
    // Add up all the bit flags you want returned.
    // Learn more here:
    $cols = "103079215104";
    // Now put your entire request together.
    // This example uses the Mozscape URL Metrics API.
    $requestUrl = "".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
    // We can easily use Curl to send off our request.
    $options = array(
    $ch = curl_init($requestUrl);
    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    // * Store URL metrics in array
    $json_a = json_decode($content);
    // * Assign URL metrics to separate variables
    $MozRank = $json_a->umrp;
    $theUrl = $json_a->uu;
    $title = $json_a->ut;
    Just unsure how to get that displaying in the correct columns and if the coding is correct

    Thank you in advance

  2. #2
    Join Date
    May 2012
    Thanked 1 Time in 1 Post


    I have found a new script that works but only if the domain name is hardcoded in the script but can't work out how to get the da and pa info for domain names already stored in a mysql database, below is a new script I found

    	 //  access id and secret key from
    	$accessID = "ACCESS ID";
    	$secretKey = "SECRET KEY";
    	//Set Expires time in future here 5 minutes.
    	$expires = time() + 300;
     // Need to put linefeed between your AccessID and Expires time variable.
    	$SignInStr = $accessID. "\n" .$expires;
     // Create your binary Signature from hmac hash.
    	$binarySignature = hash_hmac('sha1', $SignInStr, $secretKey, true);
     // base64-encode signature then urlencode it's output.
    	$SafeSignature = urlencode(base64_encode($binarySignature));
     // Url for which we want url metrics.
    	$objURL = "";
      // sum all the bit flags you want to be returned.
    	// Find bit flag values visit
    	$flags = "103079215108";
    	// combine everythind create request url and here We use URL Metrics API.
    	$reqUrl = "".urlencode($objURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$SafeSignature;
     // send request with php-curl.
    	$opts = array(
     $curlhandle = curl_init($reqUrl);
    	curl_setopt_array($curlhandle, $opts);
    	$content = curl_exec($curlhandle);
    	$resObj = json_decode($content);    //decode the json object and fetch results
    	echo "Domain Authority : " . $resObj->{'pda'};
    	echo "<br><br>";
    	echo "Page Authority : " . $resObj->{'upa'};

Similar Threads

  1. Facebook integration with PHP
    By hemi519 in forum PHP
    Replies: 1
    Last Post: 03-29-2011, 08:12 PM
  2. facebook integration
    By silver163 in forum JavaScript
    Replies: 1
    Last Post: 01-13-2010, 05:28 AM
  3. Paypal php integration
    By khatri in forum PHP
    Replies: 6
    Last Post: 12-29-2008, 12:56 AM
  4. iwebtools integration
    By Wassouf in forum JavaScript
    Replies: 4
    Last Post: 08-09-2007, 12:35 PM
  5. Need help with php integration
    By siljo in forum PHP
    Replies: 0
    Last Post: 10-15-2006, 07:30 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts