简体   繁体   English

我试图打开一个https网站,在PHP中使用curl。 但我得到一个空白页面

[英]I am trying to open a https site , using curl in php . But I am getting a blank page

I am trying to open a https site , using curl in php . 我试图打开一个https网站,在PHP中使用curl。 But I am getting a blank page .Though when i checked I can find that the httpcode returned is 200. I am able to open the same page using the browser . 但是我得到一个空白页面。虽然我检查过,但我发现返回的httpcode是200.我可以使用浏览器打开同一页面。 I have disbaled the ssl verifyer and ssl_verify host since the host name and the name in the certifcate was different . 我已经废除了ssl verifyer和ssl_verify主机,因为主机名和certifcate中的名称不同。

Here is my code any help would be useful 这是我的代码,任何帮助都会有用

<?php
$url = "https://abcde.com/";
$ch = curl_init($url);
echo "init";
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 200);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERPWD,"uname:pwd");
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,1);
$curl_scraped_page= curl_exec($ch);
$httpCode=curl_getinfo($ch, CURLINFO_HTTP_CODE); 
if(!$curl_scraped_page)
{
    echo "first learn";
}
echo $httpCode ;
echo $curl_scraped_page;
curl_close($ch);
?>

Try using CURLOPT_USERAGENT to set the user agent to the same one your browser uses. 尝试使用CURLOPT_USERAGENT将用户代理设置为浏览器使用的用户代理。 They may be using user agent sniffing. 他们可能正在使用用户代理嗅探。

设置此选项:

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在尝试使用PHP Curl填写表格 - I am trying to fill in a form by using PHP Curl 当我使用 wsdl 和端点 url 执行我的 curl php 请求时得到空白响应 - Getting Blank response when i am executing my curl php with request with wsdl and endpoint url 我正在尝试使用 php 在 mysql 中动态插入数据,但出现语法错误 - I am trying to dynamically insert data in mysql using php and i am getting syntax error 我正在使用php,json服务,而我在执行以下代码时却得到了空白页,数据库中未更新任何数据……如果出错,请更正我 - Am using php, json services while i execute below code i am getting a blank page, no data updated in database…correct me if wrong 如何使用php curl正确调用API? 我收到401的http状态码 - How do i call an API using php curl correctly? I am getting http status code of 401 我没有收到来自 PHP 中 Curl 请求的预期响应 - I am not getting expected response from Curl request in PHP 我试图将我的HTML网站更改为PHP,但它显示错误? - i am trying to change my html site to php but it shows error? 为什么我可以使用php cURL访问管理面板而不发送用户名和密码 - Why I am getting access to the admin panel without sending username and password by using php cURL PHP-如何获取该网站的curl网页内容 - php - how can i getting a web page content with curl for this site 当我尝试使用带有PHP的date函数显示时间时,为什么会得到“ 4:00”? - why am I getting '4:00' when I'm trying to display time using the date function with php?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM