天天看点

PHP函数file_get_contents()使用 https 协议时报错:SSL operation failed

报错提示:

总之就是https报错,采集不到数据

直接上代码:

$stream_opts = [

"ssl" => [
    "verify_peer"=>false,
    "verify_peer_name"=>false,
]           

];

$response = file_get_contents("https://xxx.xxx.xxx",false, stream_context_create($stream_opts));

使file_get_contents()函数跳过https验证,完美解决