CURL返回空白数据但在Postman上很好

时间:2016-06-26 17:07:44

标签: php curl

<?
include_once("simple_html_dom.php");

$cookie = "";
$ch = curl_init ();
curl_setopt($ch,CURLOPT_URL,"https://ebr1m.hasil.gov.my/SemakanKeluar.aspx?i=%2b2n0eU1wWL95mKKlIgQE%2bifqhY%2bMr3Vm%2b7cRxZnZsyI%3d");

echo $_GET['id'];

curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE,$cookie);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$data = curl_exec($ch);
curl_close($ch);

$doc = str_get_html($data);
echo $doc;

?>

我试过Postman,没关系。但是当我使用curl(具有相同的请求数据)时,它不会返回任何内容。

1 个答案:

答案 0 :(得分:0)

我使用你的代码,一切都很好。

你试过

var_dump( $data );
var_dump( $doc );