To go along with our new BlogRank Top 100 List and our BlogRank widget, here is a new getperformancingrank Metrics API function to allow you to programmatically retrieve the BlogRank for a domain.
Using this API call is simple, just provide it with the domain you want BlogRank for (ensuring you correctly match the domain to what was entered into metrics, eg. performancing.com NOT www.performancing.com). If the blog has public stats set you do not need to use an Auth key, otherwise you will need to supply an auth for your own non-public blogs.
Example Code
“, ““);
print “Your BlogRank is: $text”;
/*
** function to return a specific XML element contents by name
*/
function GetElementByName(&$xml, $start, $end) {
global $pos;
$startpos = strpos($xml, $start);
if ($startpos === FALSE) {
return FALSE;
}
$endpos = strpos($xml, $end);
$endpos = $endpos + strlen($end);
$pos = $endpos;
$endpos = $endpos – $startpos;
$endpos = $endpos – strlen($end);
$tag = substr($xml, $startpos, $endpos);
$tag = substr($tag, strlen($start));
return $tag;
}
?>
The above PHP code will go to the API and grab the XML response then using the GetElementByName function looks for and pulls out anything between “<rank>” and “</rank>”.
Metrics API
As a reminder you can find all the other API functions in our Metrics Handbook. If you do produce something cool do let us know so we can tell people about it and include it on our Community Plugins and Apps page.
2 thoughts on “HOWTO: Get BlogRank Via the API”
Your blog does not have public stats enabled and you are not passing an auth key in your request, do one or the other and it will show your rank for you
This is not working, it gets a blank rank. And when you go directly to the url it is parsing you get an xml doc with an error code:
http://performancing.com/perfstats/api.php?blog_domain=wslrss.com&action=getperformancingrank
-
I’m glad you can still see your rank at:
http://performancing.com/blogrank/widgets
Comments are closed.