When 200 is not OK sm

 

LinkScrubber API

LinkScrubber supplies a simple API for sites like directories, CMS or otherwise have all their external links in a database and wish to validate each link directly and avoid a site crawl. Additionally, this API can be used in real-time for checking new URL submissions or even validating URLs in forum posts, blogs and more! To be added to the wait list for alpha developer keys, send your email request to "devkey" @ this domain and include the URL of the site you want link checked if you're approved.

The simple REST API in APLHA  allows passing a single link and getting a simple XML result.

Example API call:

http://api.linkscrubber.com?v=1&key=<devkey>&url=http://example.com/missingpage.html

Example API XML return:

<?xml version="1.0"?>
<url>
	<loc>http://www.example.com/missingpage.html</loc>
	<code>705</code>
	<xcode>404-Like</xcode>
	<hlen>200</hlen>
	<clen>1200</clen>
	<time>0.8s</time>
</url>

loc Location of requested URL to test
code HTTP response code
xcode Extended Link Scrubber status information
hlen Length of header(s) returned
clen Length of content(s) returned
time Total time to retrieve content(s) in seconds
   

Example System Error XML return:

<?xml version="1.0"?>
<error>
	<code>901</code>
	<xcode>MISSING VERSION</xcode>
</error>

Sample PHP code to use Link Scrubber API

<?php 

// KEY, needed for API calls, use TEST as the initial key when integrating
$key = 'test'; 
// URL of site to test with API
$url = 'http://www.example.com'; 

// Construct the API REST call 
$apicall = "http://api.linkscrubber.com/index.php?v=1&key=$key&url=$url";

// Load the XML document returned by the API as an object
$xml = simplexml_load_file($apicall);

if ($xml) {
	$results = '';
	
	if( $xml->Errors )
	{
		// Error in the XML response, print a warning.
		$results = "Error making XML query!";
	}
	else
	{
		$loc=$xml->loc;
		$code=$xml->code;
		$xcode=$xml->xcode;
		$hlen=$xml->hlen;
		$clen=$xml->clen;
		$time=$xml->time;
		
		$results .= "<b>URL:</b> $loc<br/>";
		$results .= "<b>HTTP code:</b> $code<br/>";
		$results .= "<b>Extended code:</b> $xcode<br/>";
		$results .= "<b>Header Length(s):</b> $hlen<br/>";
		$results .= "<b>Content Length(s):</b> $clen<br/>";
		$results .= "<b>Total time:</b> $time<br/>";
	}
}
else {
	// No XML response, print an error
	$results = "No XML response!";
}

echo $results;
?>

See list of HTTP codes and Extended codes for response values