Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中使用curl?_Php_Curl - Fatal编程技术网

如何在php中使用curl?

如何在php中使用curl?,php,curl,Php,Curl,我正在尝试使用cURL。 我想通过使用cURL的POST请求发送一个号码。 回应地点: 如果号码错了:回答:对不起,号码错了 如果数字正确,请转到其他页面html。 我使用以下代码: $number = "+98*******"; // enter a phone number $data = array('phone' => $number); $url = "https://example_page1/auth/login"; $ch = curl_init(); curl_setop

我正在尝试使用cURL。 我想通过使用cURL的POST请求发送一个号码。 回应地点: 如果号码错了:回答:对不起,号码错了 如果数字正确,请转到其他页面html。 我使用以下代码:

$number = "+98*******"; // enter a phone number
$data = array('phone' => $number);
$url = "https://example_page1/auth/login";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($ch);


echo "\n" . substr($number, 0, -7) . "******* :" . $res; 
?> 
上面的代码工作正常。 当号码错误时:回答:*********:对不起,号码错误

当数字正确时 是给空页。 我想翻到第二页,给出标题,。。。 但给空页。
问题是什么؟

检查错误日志。此外,不要忘记在之后关闭连接,curl_close$ch;该页面如何进行重定向?卷曲只会在头部执行3xx重定向。如果是通过javascript,你必须自己做。谢谢。给出:500错误内部服务器错误如果我们看不到日志,它给出500错误的事实没有多大帮助。检查日志,看看上面写的是什么。