Skip to content

Instantly share code, notes, and snippets.

@son0fhobs
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save son0fhobs/9459719 to your computer and use it in GitHub Desktop.
Save son0fhobs/9459719 to your computer and use it in GitHub Desktop.
Use serp scrape instead - Moz Free API in Serps
/* Still a work in progress */
// Never mind $('#search iframe').src has all the vals I need Gah!!!
// Snap. Make the call to my own server, passing in all the necessary serp info, then the php request to Moz.
// https://github.com/seomoz/SEOmozAPISamples/blob/master/php/signed_authentication_sample.php
// Or easier yet, just export
// this should really be made object oriented
// http://apiwiki.moz.com/anatomy-of-a-mozscape-api-call
// http://apiwiki.moz.com/url-metrics
/*
Bit Cols
DA - 68719476736
PA - 34359738368
mozrank - 16384
// don't use as included in DA and PA
links to url - 2048
External Equity Links - 32
*/
var urls = ['moz.com', 'raventools.com', 'wordstream.com'];
var colVals = [
{
name:'DA',
bits:68719476736,
response: 'pda'
},{
name:'PA',
bits:34359738368,
response: 'upa'
},{
name:'MozRank',
bits:16384,
response: 'umrp' // normalized
altResponse: 'umrr' // raw
}
];
// limit = default = 25, max = 50
// different call for root domain - strip to root domain yourself as that's a premium moz api call.
var api_call_attrs = {
endpoint:'url-metrics',
url: '',
parameters: '', // calculated later
accessId:'',
expires:'',
signature:''
};
// get sum of col vals
colTotal = 0;
var i=0;
max = colVals.length;
for(i=0; i<max;i++){
colTotal += colVals[i].bits;
}
api_call_attrs.parameters = 'Cols='+colTotal+'&Limit=25',
var authentication = 'AccessID='+api_call_attrs.accessId+'&Expires='+api_call_attrs.expires+'&Signature='+signiture.signature;
var api_url = '';
max = url.length;
for(i=0; i<max;i++){
api_call_attrs.url = urls[i];
// make calls here for each url
api_url = 'http://lsapi.seomoz.com/linkscape/'+api_call_attrs.endpoint+'/'+api_call_attrs.url+'?'+api_call_attrs.parameters+authentication;
// now use jquery ajax
// can this be done with post?
}
// http://lsapi.seomoz.com/linkscape/url-metrics/moz.com%2fblog?Cols=4&AccessID=member-cf180f7081&Expires=1225138899&Signature=LmXYcPqc%2BkapNKzHzYz2BI4SXfC%3D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment