Author Avatar

Fabrizio S.

0

Share post:

Ci occupiamo adesso in questo nuovo articolo delle API Key di Moz. Ossia dei codici tramite i quali un’azienda ci permettere di accedere ad alcuni dati sensibili. Ovviamente in questo caso ci stiamo occupando del mondo ambito SEO.

 

Prima di partire un attimo di storia .

 

Che cosa è Moz

 

Si tratta di una casa specializzata nel SEO ed in particolare nello stabilire un valore della pagina. Sono infatti famosi nel mondo SEO WEB i termini DA e PA. Ossia Domain Autority che tiene conto di quanto sono buoni i collegamenti verso il vostro sito. Mentre il Page Autority tiene conto di quanto è buono livello deila pagina del vostro sito. In dettaglio trovate tutto su Domain Autority e Page Autority.

 

Quindi se volete sapere un determinato valore di un determinato sito dovrete andare direttamente sul sito  di Moz . Oppure se volete che altri utenti visionino tali informazioni dal vostro sito dovrete ricorrere necessariamente alle API di Moz. Ne offre di due tipi. Fino a 1 query ogni 10 secondi e fino 25000 mila la mese. Sopra dovrete pagare. Questo ad oggi poi ovviamente sono parametri mutevoli. Quindi il primo passo è avere un accesso a Moz. Fatto questo richedete l‘API KEY

 

A questo punto potrete accedere tramite questi dati a tutti i parametri di cui siete interessati. La lista dei dai a cui vi permette di accedere è veramente molto vasta. Si va dalle metriche inbound, social ai link di qualità , DA, PA etc. etc.

Diciamo che i parametri principali sono

 

I metodi di accesso sono comuni a tutti. Vediamo qualche esempio per chiarire.

 

Il primo passo comune a tutti è quello di inserire due variabili con le API Key di MOZ



$accessID = "XXXXXXXXXXXXXXXX";
$secretKey = "XXXXX-XXXXXXXXXXX-XXXXXXXXXX";;


// Impostate un periodo di scadenza non eccessivamente lungo. 5 minuti è perfetto

$expires = time() + 300;


// e mettetelo insieme all'access ID con cui farete la richiesta


$stringToSign = $accessID."\n".$expires;


//il tutto viene segretato tramite un codice crittografato in quanto in rete non si deve vedere nulla.
$binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
$urlSafeSignature = urlencode(base64_encode($binarySignature));





//introciamo il col ossia il servizio a cui volete accedere che trovate nei tre link che ho messo sopra


$cols = "68719476736";


//componiamo l'url per la richiesta


$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.
$batchedDomains = array('www.dominio1.ext', ''www.dominio2.ext', ''www.dominio3.ext');


// fate l'encode per porlo in formato json

$encodedDomains = json_encode($batchedDomains);


// Usate il modo  Curl per mandare la vostra richiesta
// settiamo il ritorno a vero e il postfield con il valore del json dell'encode sopra e inoltriamol a richiesta con il metodo curl appunto
$options = array(
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_POSTFIELDS => $encodedDomains
 );
$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close( $ch );

/// decodifichiamo la risposta ottenuta che è in formato json e la mandiamo a video
$contents = json_decode($content);
print_r($contents);

 

Questo è un esempio abbastanza esaustivo se volete ve ne mostriamo altri


// Get your access id and secret key here: https://moz.com/products/api/keys
$accessID = "xxxxxxxxxxx";
$secretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// Set your expires times for several minutes into the future.
// An expires time excessively far in the future will not be honored by the Mozscape API.
$expires = time() + 300;
// 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));
// Specify the URL that you want link metrics for.
$objectURL = "www.ilblogdiuominiedonne.net";
// 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 = "103079215108";

//$cols="128";
// Put it all together and you get your request URL.
// This example uses the Mozscape URL Metrics API.
$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
// Use Curl to send off your request.
$options = array(
 CURLOPT_RETURNTRANSFER => true
 );
$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
print_r($content);

echo "<br>////////////////////////////////////////////////////////////////////<br><br><br><br><br>";

$obj = json_decode($content);
echo($obj->upa); // Doe


echo "<br>///////////////////////////LINK//////////////////<br><br><br><br><br>";


$cols="549755813888";
// Put it all together and you get your request URL.
// This example uses the Mozscape URL Metrics API.
$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
// Use Curl to send off your request.
$options = array(
 CURLOPT_RETURNTRANSFER => true
 );
$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
print_r($content);

echo "<br>///////////////////////////Lhttp status code//////////////////<br><br><br><br><br>";


$cols="536870912";
// Put it all together and you get your request URL.
// This example uses the Mozscape URL Metrics API.
$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
// Use Curl to send off your request.
$options = array(
 CURLOPT_RETURNTRANSFER => true
 );
$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
print_r($content);


echo "<br>///////////////////////////EQUITY LINK 256 link che passano valore esterni interni al sito//////////////////<br><br><br><br><br>";


$cols="256";
// Put it all together and you get your request URL.
// This example uses the Mozscape URL Metrics API.
$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
// Use Curl to send off your request.
$options = array(
 CURLOPT_RETURNTRANSFER => true
 );
$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
print_r($content);


echo "<br>///////////////////////////EQUITY LINK 256 link che passano valore esterni interni al sito//////////////////<br><br><br><br><br>";


$cols="256";
// Put it all together and you get your request URL.
// This example uses the Mozscape URL Metrics API.
$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
// Use Curl to send off your request.
$options = array(
 CURLOPT_RETURNTRANSFER => true
 );
$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
print_r($content);


echo "<br>///////////////////////////LINK TOTALI//////////////////<br><br><br><br><br>";


$cols="2048";
// Put it all together and you get your request URL.
// This example uses the Mozscape URL Metrics API.
$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
// Use Curl to send off your request.
$options = array(
 CURLOPT_RETURNTRANSFER => true
 );
$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
print_r($content);

echo "<br>/////////////////////////DOMAIN AUTORITY e PAGE AUTORIYU//////////////////<br><br><br><br><br>";

$expires = time() + 300;
// 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));
// Specify the URL that you want link metrics for.
$objectURL = "www.noirsolutions.net";
// 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 = "103079215108";
// Put it all together and you get your request URL.
// This example uses the Mozscape URL Metrics API.
$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
// Use Curl to send off your request.
$options = array(
 CURLOPT_RETURNTRANSFER => true
 );
$ch = curl_init($requestUrl);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
print_r($content);

 

 

che come potete vedere fa piu’ richieste contemporanemaente.

Differenza tra URI e URL e loro significato termine
Libreria PHP pChart Esempi per fare grafici