Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
youfeed opened this issue Mar 28, 2023 · 1 comment
Open

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

youfeed opened this issue Mar 28, 2023 · 1 comment

Comments

@youfeed
Copy link
Contributor

youfeed commented Mar 28, 2023

服务器A:

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

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

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

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

@youfeed
Copy link
Contributor Author

youfeed commented Mar 28, 2023

有那么点 搞清楚了,在这里写下备用
第一 你设置是'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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant