这是一个通过 php 远程上传文件到 rapidshare 的简单功能,需要用户名和密码并在您的服务器中激活 curl。
where 是全局的,你可以在函数外的任何地方设置用户名和密码
function upload_Rapidshare_remote($fileurl)
{
global $username, $password;
//Define the variables for post
$url = 'http://rapidshare.com/cgi-bin/rsapi.cgi';
$fields = array('sub' => "remotegets",
'cmd' => "addjob",
'login' => $username,
'password' => $password,
'urls' => urlencode($fileurl)
);
//Create url for post data
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//Open the Connection
$ch = curl_init($url);
//Send Post Data
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//Execute
$result = curl_exec($ch);
//Close the connection
curl_close($ch);
//return....
return;
}
使用方法
upload_Rapidshare_remote('http://www.mysite.com/file.zip');