I'm working on setting up credit card processing and needed to use a workaround for CURL. The following code worked fine when I was using the test server (which wasn't calling an SSL URL), but now when I am testing it on the working server with HTTPS, it's failing with the error message "failed to open stream".

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);
}

推荐答案

Try the following script to see if there is an https wrapper available for your php scripts.

$w = stream_get_wrappers();
echo 'openssl: ',  extension_loaded  ('openssl') ? 'yes':'no', "\n";
echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
echo 'wrappers: ', var_export($w);

the output should be something like

openssl: yes
http wrapper: yes
https wrapper: yes
wrappers: array(11) {
  [...]
}

Php相关问答推荐

基于验证动态更改输入字段类(名称密码)&

获得客户S在WooCommerce为期1年的总支出

管理员订单列表中的自定义列与WooCommerce 8.6.1一起消失

在php中有没有办法比较两个包含相同枚举类型的枚举数组

Msgraph-sdk-php v2如何从返回对象中获取数据?

WooCommerce在store 页面上显示兼容多语言的产品属性

Laravel数据表在一个视图中传递两个实例

基于不用于变体的产品属性隐藏多个WooCommerce发货方式

将日期数组排序为年->;月

FlySystem v3:使用本地适配器时出现问题

在WooCommerce存档页面中显示可变产品的库存变化属性

PHP 支持 APNG 文件吗?

如何使用 PHP 将带有图像的文本上传到 Linkedin?

WooCommerce 以编程方式添加的费用不会持续存在

PHP:数组的等边

使用用户元数据填写 woocommerce checkout 字段

仅允许减少 WooCommerce 中已完成订单的库存数量

为 WordPress 页面创建新功能

输出每个可能的产品选项

使用 v-for 的存储链接中的 Img src 在 Laravel vuejs 中不起作用