日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php curl 发送https请求失败,php的curl扩展无法发起https请求

發布時間:2024/4/11 php 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php curl 发送https请求失败,php的curl扩展无法发起https请求 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

很奇怪的是,file_get_content函數可以對https地址發起請求并且收到響應報文,但是curl就不可以,這是什么原因呢?我已經安裝了openssl擴展。

function fetch($url, $cookie=null, $postdata=null, $headers=null){

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

echo "$url\n";

if (!is_null($headers)) curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

if (!is_null($postdata)) curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);

if (!is_null($cookie)) curl_setopt($ch, CURLOPT_COOKIE, $cookie);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_TIMEOUT, 20);

$re = curl_exec($ch);

curl_close($ch);

return $re;

}

echo fetch("http://baidu.com"); // 有輸出

echo fetch("https://baidu.com"); // 無輸出

Administrator@changwei MINGW64 /d/www/test

$ php ./test.php

http://baidu.com

Administrator@changwei MINGW64 /d/www/test

$ php ./test.php

https://baidu.com

$ php -m

[PHP Modules]

bcmath

bz2

calendar

Core

ctype

curl

date

dom

ereg

fileinfo

filter

ftp

gd

hash

iconv

json

libxml

mbstring

mcrypt

mhash

mongo

mysql

mysqli

mysqlnd

odbc

openssl

pcre

PDO

pdo_mysql

pdo_sqlite

phalcon

Phar

redis

Reflection

session

SimpleXML

SPL

sqlite3

standard

tokenizer

wddx

xdebug

xml

xmlreader

xmlwriter

xsl

zip

zlib

[Zend Modules]

Xdebug

總結

以上是生活随笔為你收集整理的php curl 发送https请求失败,php的curl扩展无法发起https请求的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。