wandering php developer with some books about reality ..
Rapidshare Link Checker API – Easy PHP Code to Check RapidShare Files
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 ?
No trackbacks yet.
Transfer your website across servers using SSH, TAR, MYSQLDUMP
about 1 year ago - 3 comments
Use SSH Piping techniques to Send files, Import databases from server to server.. the quick and easy way.
about 11 months ago
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.
about 10 months ago
Hello from Russia!
Can I quote a post in your blog with the link to you?
about 10 months ago
sure, please feel free to do so as long as u mention the source ..
about 9 months ago
Thanks
This has speeded up link checking 500% for my site.
about 9 months ago
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 ..
about 8 months ago
you know file_get_contents() uses fopen() which is slow…try curl instead
great post dude!
about 8 months ago
thanks for the tip, i shall add a way to use curl instead , this really should be better in production env.
about 4 months ago
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
about 4 months ago
you can easily trim the url passed to the function, for example :
rs_check( trim($url) );
about 4 months ago
yes, it works perfectly
Thank you very much shadyvb
about 4 months ago
I’m glad it worked for you