我是这样尝试的新手,我试图在 magento2 中使用 https 获取令牌,它在这里不起作用我的代码
<?php
$base_url="https://myurl.com/";
$domain="myurl.com";
$url = $base_url.'index.php/rest/V1/integration/admin/token';
$body = '{"username":"ApiUser", "password":"ApiPass"}';
$context_options = array (
'https' => array (
'method' => 'POST',
'header'=> "Content-type: application/json"
'content' => $body
),
'ssl' => array('SNI_enabled'=>true,'SNI_server_name'=> $domain)
);
$context = stream_context_create($context_options);
$token = json_decode(file_get_contents($url, false, $context));
echo $token; echo "<br/>";
?>
Run Code Online (Sandbox Code Playgroud)
请帮忙,提前致谢。