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 ?
Rapidshare is simply the most popular file sharing site. i mostly download and upload my files on them. i also bought 2 premium accounts from rapidshare, one for me and the other one for my girlfriend.
Hello from Russia!
Can I quote a post in your blog with the link to you?
sure, please feel free to do so as long as u mention the source ..
Thanks
This has speeded up link checking 500% for my site.
I’m glad it works for you!
I just love automating stuff, I’ve tons of scripts to do daily or repeatitve tasks i usually spend time at my server ..
you know file_get_contents() uses fopen() which is slow…try curl instead
great post dude!
thanks for the tip, i shall add a way to use curl instead , this really should be better in production env.
Hi,
in the regexp is something wrong because when it checks good link but with space at the end, it return me a bad $fStatus.
Can you check this?
Greetings from Poland
you can easily trim the url passed to the function, for example :
rs_check( trim($url) );
yes, it works perfectly
Thank you very much shadyvb
I’m glad it worked for you