Php 使用Rapidshare API检查文件是否可下载

Php 使用Rapidshare API检查文件是否可下载,php,api,rapidshare,Php,Api,Rapidshare,我对这个API是新手,所以我不知道如何很好地使用它。我想在C、PHP或AppleScript上制作一个应用程序,以检查文件是否可下载。我只需要知道如何正确地发送请求 我阅读了API文档,但仍然不知道如何获取返回值 有人能帮我吗 祝大家节日快乐() 从现在起,谢谢。请使用以下内容: http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&type=prem&login=MY_USERNAME& password=MY_PASSWO

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

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

有人能帮我吗

祝大家节日快乐() 从现在起,谢谢。

请使用以下内容:

http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&type=prem&login=MY_USERNAME& password=MY_PASSWORD&files=5044438&filenames=test1.rar http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&type=prem&login=MY_USERNAME& password=MY_password&files=50444438&filenames=test1.rar 此调用使用checkfiles_v1子例程,根据API文档:

subroutine=checkfiles_v1 Description: Gets status details about a list of given files. (files parameter limited to 3000 bytes. filenames parameter limited to 30000 bytes.) Parameters: files=comma separated list of file ids filenames=comma separated list of the respective filename. Example: files=50444381,50444382 filenames=test1.rar,test2.rar incmd5=if set to 1, field 7 is the hex-md5 of the file. This will double your points! If not given, all md5 values will be 0 Reply fields: 1:File ID 2:Filename 3:Size (in bytes. If size is 0, this file does not exist.) 4:Server ID 5:Status integer, which can have the following numeric values: 0=File not found 1=File OK (Anonymous downloading) 2=File OK (TrafficShare direct download without any logging) 3=Server down 4=File marked as illegal 5=Anonymous file locked, because it has more than 10 downloads already 6=File OK (TrafficShare direct download with enabled logging. Read our privacy policy to see what is logged.) 6:Short host (Use the short host to get the best download mirror: http://rs$serverid$shorthost.rapidshare.com/files/$fileid/$filename) 7:md5 (See parameter incmd5 in parameter description above.) Reply format: integer,string,integer,integer,integer,string,string 子例程=检查文件\u v1 描述:获取给定文件列表的状态详细信息。(文件参数限制为3000字节。文件名参数限制为30000字节。) 参数:files=以逗号分隔的文件ID列表 filenames=各个文件名的逗号分隔列表。示例:files=504438150444382 filenames=test1.rar,test2.rar incmd5=如果设置为1,则字段7是文件的十六进制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) 答复格式:整数、字符串、整数、整数、整数、字符串、字符串 您可以利用回复中的状态,如果其值为1,则表示文件可下载。

下面是PHP中的程序:


好,但如何将此状态存储在变量中?如果可能的话,给我一个C、applescript或php的例子。从现在起,谢谢你,Thiago。请查看这篇博文。虽然它是用Java编写的,但它可能会对你有所帮助。它检查rapidshare.com上的文件状态
<?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>";

?>