Я получаю сообщение об ошибке при подключении API заказа Magento2 - PullRequest
0 голосов
/ 05 сентября 2018

Исправляемая фатальная ошибка: объект класса stdClass не может быть преобразован в строку в этой строке

curl_setopt ($ ch, CURLOPT_HTTPHEADER, массив ("Тип содержимого: application / json "," Authorization: Bearer ". 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);
...