[英]Rapidgator API Direct Download Link Error
伙计们,我目前正在研究文件托管高级链接生成器,基本上它将是一个网站,您无需购买高级帐户即可从该网站获得uptobox,rapidgator,uploaded.net和其他文件托管站点的高级链接。 基本上,我们代表用户购买此网站的帐户,并以低价提供此服务。 因此,当我设置Rapidgator的直接下载链接的API时,我可以获取该链接,但会话已结束。 我正在尝试通过软件而不是通过手动编码来使用该API,而我正面临着这个问题
所以,我已经从Tihs网站获得Rapidgator API参考: - https://gist.github.com/Chak10/f097b77c32a9ce83d05ef3574a30367d
因此,我正在使用调试软件执行以下操作,并且获得了成功响应,但是当我在浏览器中打开该URL时,它显示会话ID失败。
所以这是我正在做的步骤在https://rapidgator.net/api/user/login上发送带有用户名和数据的发帖请求,并且我正在获取此输出
{"response":{"session_id":"g8a13f32hr4cbbbo54qdigrcb3","expire_date":1542688501,"traffic_left":"13178268723435"},"response_status":200,"response_details":null}
现在,我在此URL上发送了一个get请求(我尝试了“过分发布请求”,但发生了同样的事情),会话ID和URL嵌入在URL https://rapidgator.net/api/file/download?sid=&url =中,我正在获得此输出
{"response":{"url":"http:\/\/pr56.rapidgator.net\/\/?r=download\/index&session_id=uB9st0rVfhX2bNgPrFUri01a9i5xmxan"},"response_status":200,"response_details":null}
当我尝试通过浏览器从网址下载文件时,显示“会话无效”,有时打开连接错误过多
错误链接: -https : //i.imgur.com/wcZ2Rh7.png成功响应:-https: //i.imgur.com/MqTsB8Q.png
Rapidgator需要使用不同的URL将其api击中3次。
$cookie = $working_dir.rand();
$headers = array("header"=>"Referer: https://rapidgator.net");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://rapidgator.net/api/user/login");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=email@domain.ext&password=myplaintextpassword");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close ($ch);
$rapidgator_json = json_decode($result,true);
return array($rapidgator_json['response']['session_id'],$cookie);
http://rapidgator.net/api/user/login (这是初始登录)上面的链接为您提供了所需的会话ID。 响应为JSON
现在,我们需要一个下载链接,该链接将使我们无需登录到人工输入表单即可进行下载。 因此,我们将使用其api来使用从第一个网址获得的初始会话ID请求下载链接。
$headers = array("header"=>"Referer: http://rapidgator.net/api/user/login");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://rapidgator.net/api/file/download?sid=$rapidgator_session&url=$rapidgator_file");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $working_dir.$rapidgator_cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $working_dir.$rapidgator_cookie);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close ($ch);
$rapidgator_json = json_decode($result,true);
return array($rapidgator_json['response']['url']);
基本上,我们通过Rapidgator给我们提供的会话ID,前提是您已正确通过了一个有效的帐户。 然后,我们包含您获得的源URL(链接到文件) http://rapidgator.net/api/file/download?sid=$rapidgator_session&url=$rapidgator_file
之后。 Rapidgator将返回带有URL的JSON响应,您可以使用该URL来获取相关文件。 这使您可以使用所需的任何下载方法,因为该链接是会话URL,在短时间内有效。
$rapidgator_json['response']['url']
上面的所有代码都不完整。 建议对json响应进行一些额外的检查,以了解可能的错误/限制。 我最终使用了函数,但这足以让您了解应该做什么。 Rapidshare API还有其他数据,可用于确定您是否超出了每日配额。 会话网址将持续多长时间等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.