可捕获的致命错误:无法在此行上将stdClass类的对象转换为字符串
curl_setopt($ ch,CURLOPT_HTTPHEADER,array(“ Content-Type: application / json“,”授权:承载“。json_decode($ token)));
$userData = array("username" => "xxxx", "password" => "xxxxxx");
$ch = curl_init("http://magento2.local.com/index.php/rest/V1/integration/admin/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
$ch = curl_init("http://magento2.local.com/index.php/rest/V1/orders/1");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
$result = curl_exec($ch);
$result = json_decode($result, 1);
echo '<pre>';print_r($result);