处理ErrorException(E_NOTICE)未定义偏移量:0

问题描述 投票:0回答:1
I am trying to access the elements within the text JSON reference from the call, for example, I am trying to access the item (content)

在JSON内,但继续向我显示错误消息,代码有效,并显示JSON文件的全文没问题是否有类似的PHP lavarel方法可以用作arrylist或用于获取响应中的元素

$client = new Client();
$request = $client->post('http://localhost:4567/user/login', [
                'headers' => ['Content-Type' => 'application/json'],
                'body' => json_encode($data),
          ]);
$request= json_decode($request->getBody(), true);
return $request[0];
api laravel-5 guzzlehttp
1个回答
1
投票

您的代码应为

use GuzzleHttp\Client; $client = new Client(); $request = $client->post('http://localhost:4567/user/login', [ 'headers' => ['Content-Type' => 'application/json'], 'body' => json_encode($data), ]); return $request->getBody();
© www.soinside.com 2019 - 2024. All rights reserved.