【问题标题】:Using Rapidshare API to check if a file is downloadable使用 Rapidshare API 检查文件是否可下载
【发布时间】:2011-05-10 08:47:29
【问题描述】:

我是这个 API 的新手,所以我不知道如何很好地使用它。我想在 C 或 PHP 或 AppleScript 上创建一个应用程序来检查文件是否可下载。我只需要知道如何正确发送请求。

我阅读了 API 文档,但我仍然不知道如何获取返回值。

谁能帮帮我?

祝大家节日快乐 =) 从现在开始谢谢。

【问题讨论】:

标签: php api rapidshare


【解决方案1】:

使用类似的东西:

http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&type=prem&login=MY_USERNAME& 密码=MY_PASSWORD&files=5044438&filenames=test1.rar

此调用使用了根据 API 文档的 checkfiles_v1 子例程:

子程序=checkfiles_v1 描述:获取有关给定文件列表的状态详细信息。 (文件参数限制为 3000 字节。文件名参数限制为 30000 字节。) 参数:files=逗号分隔的文件ID列表 filenames=逗号分隔的相应文件名列表。示例:文件=50444381,50444382 文件名=test1.rar,test2.rar incmd5=如果设置为 1,则字段 7 是文件的 hex-md5。这将使您的积分翻倍!如果没有给出,所有 md5 值都将为 0 回复字段: 1:文件ID 2:文件名 3:大小(以字节为单位。如果大小为0,则该文件不存在。) 4:服务器ID 5:状态整数,可以有以下数值: 0=找不到文件 1=文件正常(匿名下载) 2=文件正常(TrafficShare 直接下载,无需任何记录) 3=服务器停机 4=文件标记为非法 5=匿名文件被锁定,因为它已经有超过 10 次下载 6=文件正常(TrafficShare 直接下载并启用日志记录。阅读我们的隐私政策以查看记录的内容。) 6:短主机(使用短主机获取最佳下载镜像:http://rs$serverid$shorthost.rapidshare.com/files/$fileid/$filename) 7:md5(见上面参数说明中的参数incmd5。) 回复格式:integer,string,integer,integer,integer,string,string

您可以使用回复中的状态,如果它的值为 1,则表示该文件是可下载的。

下面是 PHP 程序:

Click here to see the server reply

<?php

// This PHP script check if a file is publicly downloadable
// I've taken a sample file: 
// http://rapidshare.com/files/293360186/1597494240.pdf
// which at the time of wring is available + is downloadable.

// File ID
$file_id = '293360186';

// Filename
$file_name = '1597494240.pdf';

//construct the URL.
$URL = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=$file_id&filenames=$file_name";

// Now get the response for this URL.
/* It looks something like:
   293360186,1597494240.pdf,6861070,59,1,gc,0 

   So we are just interested in field 5(Status), check if its 1(file downloadable) or 0
*/

$reply = file_get_contents($URL);
if(!$reply)
{
    die("Failed for $URL<br>");
}

$arr = explode(',',$reply);

if($arr[4] == 1)
    print "File $file_name is publicly downloadable<br>";
else
    print "File $file_name is not publicly downloadable<br>";

?>

希望这会有所帮助。

【讨论】:

  • 好的,但是如何将此状态存储在变量中?如果可能的话,给我一个 C 或 applescript 或 php 的例子。从现在开始,谢谢蒂亚戈。
猜你喜欢
  • 1970-01-01
  • 2014-12-14
  • 2016-09-17
  • 2021-07-03
  • 2016-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多