Created
October 27, 2017 05:05
-
-
Save DonPramis/d919a1dba834a5504c673563c4db3e2a to your computer and use it in GitHub Desktop.
SEO MOZ RANK and MOZ AUTHORITY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Get SEOmoz Data | |
-------------------------------------------------- */ | |
public function getSeoMoz($domain, $accessid = "", $secret = "") | |
{ | |
try | |
{ | |
$access_id = (empty($accessid) ? $_SESSION['SEOMOZ_API_ACCESSID'] : $accessid); | |
$secret_key = (empty($secret) ? $_SESSION['SEOMOZ_API_SECRETKEY'] : $secret); | |
$expires = time() + 300; | |
$stringToSign = $access_id."\n".$expires; | |
$binarySignature = hash_hmac('sha1', $stringToSign, $secret_key, true); | |
$urlSafeSignature = base64_encode($binarySignature); | |
$callback_url = "http://lsapi.seomoz.com/linkscape/url-metrics/www." . $domain . "?"; | |
$data = array( | |
'Cols' => '68719493120',// 68719476736+16384=68719493120 | |
'AccessID' => $access_id, | |
'Expires' => $expires, | |
'Signature' => $urlSafeSignature | |
); | |
$curl_response = $this->curl->get($callback_url . http_build_query($data, '', '&')); | |
if ($curl_response->headers['Status-Code'] == "200") { | |
$parse_response = json_decode($curl_response, true); | |
$domain_authority = $parse_response['pda']; | |
$moz_rank = $parse_response['umrp']; //MozRank | |
$response = array( | |
'status' => 'success', | |
'data' => array( | |
'domain_authority' => (int)round($domain_authority) | |
'moz_rank' => (int)round($moz_rank) | |
) | |
); | |
} else { | |
$response = array( | |
'status' => 'error', | |
'msg' => 'SEOMoZ Response Error.' | |
); | |
} | |
} | |
catch (Exception $e) | |
{ | |
$response = array( | |
'status' => 'error', | |
'msg' => $e->getMessage() | |
); | |
} | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment