http-client icon indicating copy to clipboard operation
http-client copied to clipboard

我发出的数组 int类型会全部变成了 string

Open youfeed opened this issue 1 year ago • 1 comments

服务器A:

$response = [
 "hello": "123456"
];

$http->request($host,$response)->getBody()->getContents(); 接收端B: $request->only(['hello']);

"data": {
      "hello": "123456"
 }

这是发送端 还是接收端 没处理

youfeed avatar Mar 28 '23 09:03 youfeed

有那么点 搞清楚了,在这里写下备用 第一 你设置是'application/json 并data 传数组,插件并不会帮你json_encode 还是会 application/x-www-form-urlencoded帮你编码

'headers' => ['Content-type'=>'application/json'],

会被编码成

"method=init&params%5Bhello%5D=123456"

1679997721571

你想发json 要自己 encode 接收端 decode

youfeed avatar Mar 28 '23 10:03 youfeed