2011-05-26 244 views
1

我正在使用readfile()來通過服務器從Rapidshare的API下載。這是相關代碼:由於SSL導致readfile()失敗

readfile("http://rs$server_id$short_host.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=$file_id&filename=$file_name&login={$account['username']}&password={$account['password']}"); 

但是當我請求的頁面,我得到這個錯誤:

Warning: readfile(http://rs869l34.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=3457766962&filename=some_file.rar&login=mylogin&password=mypassword) [function.readfile]: failed to open stream: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? in C:\xampp\htdocs\dl\downloaders\rapidshare_com.php on line 25 

按照RapidShare的API,有沒有辦法阻止其返回的SSL響應。

我是否需要配置一些特殊的包裝來處理這個或什麼?

感謝您的幫助!

+5

我不知道我是否應該幫助你Red.Riding.Hood.2011.R5的」下載.XviD-BiDA.part1.rar「 – 2011-05-27 00:00:09

+1

您需要一個支持ssl編譯的PHP版本,如錯誤消息所示。否則使用'curl'而不是'readfile'。這是兩回事。 – mario 2011-05-27 00:00:44

+0

我將如何去使用cURL?如果可以的話,我寧願使用cURL。 Afaik雖然cURL只能將文件下載到文件中,而不是流式傳輸。 – Josh 2011-05-27 00:01:55

回答

0

libCurl用於從遠程服務器下載文件,如讀取文件(http://...。)。

雖然它可以處理更細節,如cookie,post和ssl證書。閱讀更多在http://cn.php.net/manual/en/book.curl.php

能夠在php.ini捲曲和嘗試下面的代碼:

$ch=curl_init("http://rs$server_id$short_host.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=$file_id&filename=$file_name&login={$account['username']}&password={$account['password']}"); 
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); // follow http redirect 
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,true); //temporary ignore certificate error for easier testing 
$data=$curl_exec($ch); 
+1

curl_setoption現在是curl_setopt – 2017-06-16 22:31:33

相關問題