Guzzle 6: no more json() method for responses

前端 未结 6 1520
悲哀的现实
悲哀的现实 2020-12-02 08:17

Previously in Guzzle 5.3:

$response = $client->get(\'http://httpbin.org/get\');
$array = $response->json(); // Yoohoo
var_dump($array[0][\'origin\']);
         


        
6条回答
  •  一向
    一向 (楼主)
    2020-12-02 08:43

    Adding ->getContents() doesn't return jSON response, instead it returns as text.

    You can simply use json_decode

提交回复
热议问题