折雨的天空
file_get_contents(): SSL operation failed with code 1. OpenSSL Error message
2020-3-5 我好笨


今天跑之前写的一个采集,提示错误:







file_get_contents(): SSL operation failed with code 1. OpenSSL Error message



以为是升级了PHP版本到7.4的原因,结果换回原来的7.3的也提示,顺便解决了一下。



在file_get_contents前面加个配置,忽略证书验证即可。主要这里是采集,没必要做证书校验。







调整后代码:







$option=array('ssl'=>array('verify_peer' => false,'verify_peer_name' => false));
$html = file_get_contents($rd['content_url'],false,stream_context_create($option));



发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容