小编Vla*_*lad的帖子

如何通过 php Laravel 从 GuzzleHttp 响应获取 HTTP 状态答案?

我使用 php Laravel 进行开发。我从 Mailgun 作为对象接收 GuzzleHttp 响应,但无法从中获取状态。

对象是:

O:8:"stdClass":2:{s:18:"http_response_body";O:8:"stdClass":2:{s:6:"member";O:8:"stdClass":4:{s:7:"address";s:24:"test_of_json-4@zapara.fr";s:4:"name";s:10:"not filled";s:10:"subscribed";b:1;s:4:"vars";O:8:"stdClass":0:{}}s:7:"message";s:36:"Mailing list member has been created";}s:18:"http_response_code";i:200;}

我只需要最后一个数据对:

"http_response_code";i:200;

将其放入变量中,例如: $http_response_code = 200; 甚至只是它的值。

要获取我上面引用的字符串,我使用

$result_ser = serialize($result);

但还无法提取变量的值。

我也尝试过这个: $this->resultString .= \GuzzleHttp\json_decode($result_ser, true); 并收到错误。

请解释一下,如何获取/提取我需要的价值?

php laravel guzzle

5
推荐指数
1
解决办法
5522
查看次数

标签 统计

guzzle ×1

laravel ×1

php ×1