Parse my own link from Rapidshare with php + curl

Status
Not open for further replies.

ebogus

Active Member
26
2011
1
0
Please help me - I want to get rapidshare filelist and parse particular link! How to do it? Rapidshare works with JS but curl and php can't do it
 
15 comments
saninokia

For example I upload file named "MyFile.rar" to RS
And than I want to get link to this file using its name "MyFile.rar"
I upload many files and copy-paste every file it's hard. I want to do it automatically
 
When you upload using the API it returns the full url to the file you just uploaded. You have to save this in a database on your end if you want to search for it/use it later on.
 
just add a email function so that you can get download link in email.check this thread,here i have added rs upload with email function.

Code:
http://www.wjunction.com/92-development-area/144230-vbulletin-autobackup-autoupload-solution.html
 
Have a nice day B-)

Non-noob:
PHP:
<?php
	############################
	#	RapidShare search shit#
	############################
	# by Robin Houtevelts	  #
	#  robin@houtevelts.com    #
	############################
	function http($url,$post = false){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		if(!empty($post)){
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		}
		
		$return = curl_exec($ch);
		if($output === false)
			$return = 'ERROR: '.curl_error($ch);
			
		curl_close($ch);
		return trim($return);
	}
	
	$username = 'username';
	$password = 'password';
		
	$title = trim($_GET['title']);
	
	$apidata = array(
		'sub' => 'listfiles',
		'filename' => $title,
		'fields' => 'filename',
		'login' => $username,
		'password' => $password
	);
	
	$apireturn = http('https://api.rapidshare.com/cgi-bin/rsapi.cgi',$apidata);

	if(strpos($apireturn,'ERROR') === TRUE){
		echo $apireturn;
		exit;
	}
	if($apireturn == 'NONE'){
		echo 'File not found';
		exit;
	}
	
	$files = explode("\n",$apireturn);
	$urls = array();
	
	foreach($files as $file){
		$file = explode(',',$file);
		list($fileID,$filename) = $file;
		$urls[] = 'https://rapidshare.com/files/'.$fileID.'/'.$filename;
	}
	
	$urls = implode("\n",$urls);
	
	echo $urls;
?>

Noob-version ( HTML'd ):
PHP:
<?php
	############################
	#	RapidShare search shit#
	############################
	# by Robin Houtevelts	  #
	#  robin@houtevelts.com    #
	############################
	function http($url,$post = false){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		if(!empty($post)){
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		}
		
		$return = curl_exec($ch);
		if($output === false)
			$return = 'ERROR: '.curl_error($ch);
			
		curl_close($ch);
		return trim($return);
	}
	
	$username = 'username';
	$password = 'password';
?>
<html>
	<head></head>
	<body>
<?php
	if(empty($_GET['title'])){
?>

		<form action="" method="GET">
			<input type="text" name="title" />
			<input type="submit" value="Search" />
		</form>
<?php
	}else{
		
	$title = '%'.trim($_GET['title']).'%';
	
	$apidata = array(
		'sub' => 'listfiles',
		'filename' => $title,
		'fields' => 'filename',
		'login' => $username,
		'password' => $password
	);
	
	$apireturn = http('https://api.rapidshare.com/cgi-bin/rsapi.cgi',$apidata);

	if(strpos($apireturn,'ERROR') === TRUE){
		echo $apireturn;
		exit;
	}
	if($apireturn == 'NONE'){
		echo 'File not found';
		exit;
	}
	
	$files = explode("\n",$apireturn);
	$urls = array();
	
	foreach($files as $file){
		$file = explode(',',$file);
		list($fileID,$filename) = $file;
		$urls[] = 'https://rapidshare.com/files/'.$fileID.'/'.$filename;
	}
	
	$urls = implode("\n",$urls);
?>
	<textarea><?php echo $urls;?></textarea>
<?php
	}
?>
	</body>
</html>
 
Last edited:
Status
Not open for further replies.
Back
Top