我是這個API的新手,所以我不知道如何使用它。我想在C或PHP或AppleScript上創建一個應用程序來檢查文件是否可下載。我只需要知道如何正確發送請求。使用Rapidshare API來檢查文件是否可下載
我讀的API文檔,但我還是不知道如何獲得的返回值。
任何人都可以幫助我嗎?
節日快樂大家=) 因爲現在的感謝。
我是這個API的新手,所以我不知道如何使用它。我想在C或PHP或AppleScript上創建一個應用程序來檢查文件是否可下載。我只需要知道如何正確發送請求。使用Rapidshare API來檢查文件是否可下載
我讀的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
此調用利用其根據API文檔checkfiles_v1子程序:
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
您可以使用狀態從答覆,如果它的值是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。 由於現在感謝, 蒂亞戈。 – 2009-12-27 17:44:59
結帳這篇博文。雖然它是用Java編寫的,但它可以幫助你。它檢查rapidshare.com上的文件狀態http://malhar2010.blogspot.com/2011/02/using-rapidsharecom-api-to-check-file.html – 2011-05-10 00:47:29