Php 流\u上下文\u创建不使用https

Php 流\u上下文\u创建不使用https,php,api,magento2,Php,Api,Magento2,我正在RESTAPI方法中使用Magento2API的自定义代码。我的站点使用SSL进行保护。我的restapi在http上运行良好,而不是在https上运行良好,下面是我的代码 <?php $base_url="http://mysite/"; $url = $base_url.'index.php/rest/V1/integration/admin/token'; $body = '{"username":"ApiUser", "password":"ApiPass"}'; $head

我正在RESTAPI方法中使用Magento2API的自定义代码。我的站点使用SSL进行保护。我的restapi在http上运行良好,而不是在https上运行良好,下面是我的代码

<?php
$base_url="http://mysite/";
$url = $base_url.'index.php/rest/V1/integration/admin/token';
$body = '{"username":"ApiUser", "password":"ApiPass"}';
$header = 'Content-type: application/json';
$options = [    'method' => 'POST',
                'content' => $body,
                'header' => $header
           ];
$context = stream_context_create(['http' => $options]);
$token = json_decode(file_get_contents($url, false, $context));

// Some settings

$header = 'Authorization: Bearer ' . $token . "\r\n"
    . 'Content-type: application/json';
$options = [    'method' => 'GET',
                'content' => $body,
                'header' => $header
           ];
$context = stream_context_create(['http' => $options]);

$sku="1234";
$url = $base_url.'index.php/rest/V1/products/'.$sku;
$json_contents = file_get_contents($url, false, $context) . "\n";
$result = json_decode($json_contents);
echo json_encode($result);
?>
它回来了

openssl: yes
http wrapper: yes
https wrapper: yes
wrappers: array(11) {
  [...]
}
请任何人帮我解决这个问题。 提前谢谢

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