相关疑难解决方法(0)

如何让file_get_contents()与HTTPS一起使用?

我正在设置信用卡处理,需要使用CURL的解决方法.当我使用测试服务器(没有调用SSL URL)时,以下代码工作正常,但现在当我在使用HTTPS的工作服务器上测试它时,它失败并显示错误消息"无法打开流".

function send($packet, $url) {
  $ctx = stream_context_create(
    array(
      'http'=>array(
        'header'=>"Content-type: application/x-www-form-urlencoded",
        'method'=>'POST',
        'content'=>$packet
      )
    )
  );
  return file_get_contents($url, 0, $ctx);
}
Run Code Online (Sandbox Code Playgroud)

php https curl file-get-contents

99
推荐指数
8
解决办法
28万
查看次数

通过https:SSL3_GET_SERVER_CERTIFICATE使用php加载外部xml文件时出错

我无法加载xml文件.

这段代码效果很好:

$url = 'http://www.w3schools.com/xml/note.xml';
$xml = simplexml_load_file($url);
print_r($xml);
Run Code Online (Sandbox Code Playgroud)

但这一个

$url = 'https://www.boardgamegeek.com/xmlapi2/thing?id=105551';
$xml = simplexml_load_file($url);
print_r($xml);
Run Code Online (Sandbox Code Playgroud)

不起作用.我收到此错误:

警告:simplexml_load_file():SSL操作失败,代码为1. OpenSSL错误消息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证在/storage/content/59/113059/boardgamelevelup.com/public_html/index.php上失败19警告:simplexml_load_file():无法在第19行的/storage/content/59/113059/boardgamelevelup.com/public_html/index.php中启用加密警告:simplexml_load_file(https://www.boardgamegeek.com/xmlapi2/thing ?id = 105551):无法打开流:第19行/storage/content/59/113059/boardgamelevelup.com/public_html/index.php中的操作失败警告:simplexml_load_file():I/O警告:无法加载外部实体" https://www.boardgamegeek.com/xmlapi2/thing?id=105551"在第19行的/storage/content/59/113059/boardgamelevelup.com/public_html/index.php中

boardgamegeek的xml文件适用于其他网站.我应该使用不同的PHP代码来加载该xml文件吗?

php xml

3
推荐指数
2
解决办法
5797
查看次数

标签 统计

php ×2

curl ×1

file-get-contents ×1

https ×1

xml ×1