I’ve been around searching for a good tool to check share-sites files if they’re still alive or dead..

During my check, I’ve stumbled upon RS’s own link checker at http://rapidshare.com/checkfiles.html .. found that they’re using a simple API provided from RS ..

I’ve used their API before for uploading stuff from my linux machine, the whole API provided by RS was a tiny Perl script used to upload files and keep the logs saved.. it just did the job then..

But now, they’ve expanded their API to good extents .. Now you can do a lot of things using simple API calls to their website.

Anyway, back to my main target, which is a link checker for Rapidshare files..

I’ve created this small function to help me check files the easy way, for i’ll be integrating it in Wordpress at a friends website soon ..

Here you are the function :

function rs_check($url){
	if (!$url) return false;
	$files_pattern= '/\/files\/([^\/]*)\//';
	$filename_pattern= '/\/files\/.*\/(.*)/';
	preg_match($files_pattern, $url, $matches_id);
	preg_match($filename_pattern, $url, $matches_name);
	$res= file_get_contents("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files={$matches_id[1]}&filenames={$matches_name[1]}");
	list($fId,$fName,$fSize,$fServerId,$fStatus,$fShortHost,$fmd5) =explode(',',$res);
	return ($fStatus==1 || $fStatus==2);
}

and you can simply call the function using the following example :

if(rs_check($url)){
 echo 'This is a valid working link!';
}else{
 echo 'This is not a valid link anymore!';
}

I’ll be enhancing this with a Javascript JSON Server API .. but i guess I’ll enjoy my vacation first! ;)

You can preview my link checker from this demo Rapidshare Link Checker Demo, and the file is available for download and including from here Rapidshare Link Checker API .

Does anyone know about APIs of similar websites that can be used the same way ?