Zul*_*ulu 1 php curl fsockopen
我想把一些帖子数据发送到服务器并阅读回复.他们提供给我的网址是https://thesite.com/page/test.jsp,i尝试使用$ fp = fsockopen("https:// thesite .com/page/test.jsp",80,$ errno,$ errstr,30); 但得到了'无法找到'HTTPs''错误.使用curl发送数据但是与服务器核对,他们没有收到任何请求.还有其他办法吗?
小智 5
我有一个类似的问题,问题是curl默认情况下不会打开带有不受信任证书的网站.所以你必须禁用这个选项:curl_setopt($ c,CURLOPT_SSL_VERIFYPEER,false); 因此curl中用于发出http请求的完整脚本将是:
$c = curl_init();
//webpage to which you try to send post
curl_setopt($c, CURLOPT_URL, 'https://www.website/send_request.php');
curl_setopt($c, CURLOPT_POST, true);
// data to be sent via post
curl_setopt($c, CURLOPT_POSTFIELDS, 'var1=324213&var2=432');
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
// Get the response and close the channel.
curl_exec ($c);
// read the error code if there are any errors
if(curl_errno($c))
{
echo 'Curl error: ' . curl_error($c);
}
curl_close ($c);
Run Code Online (Sandbox Code Playgroud)