2014-11-23 45 views
1
<?php 


// 1. initialize 
$ch = curl_init(); 

// 2. set the options, including the url 
curl_setopt($ch, CURLOPT_URL, "https://somesite.edu"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

// 3. execute and fetch the resulting HTML output 
$output = curl_exec($ch); 

echo $output; 

// 4. free up the curl handle 
curl_close($ch); 

?> 

我使用npm捲曲,它確實檢索了一些東西,但是當我嘗試在PHP中它返回空白。我的問題是什麼?我已經說CURLOPT_RETURNTRANSFER爲true。在我的情況下,PHP捲曲輸出空白

+0

我測試你的腳本,它給我返回的內容。另外SSL驗證似乎不成問題。也許你被禁止或服務器期望更多的標題(例如接受,useragent) – 2014-11-23 13:32:00

回答

1

嘗試添加在你的捲髮另一種選擇:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
+0

這是否爲捲曲https? – 2014-11-23 13:34:25

+0

@Alexwood是的。我很高興這有幫助 – Ghost 2014-11-23 13:43:14