且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP Guzzle HTTP 6发送带有已编码数据的JSON

更新时间:2022-11-29 12:27:04

根据guzzle的文档 http://docs.guzzlephp.org/en/latest/request-options.html#json

According to guzzle's docs http://docs.guzzlephp.org/en/latest/request-options.html#json

您可以将已经编码的json直接传递到body参数中

You can pass the already encoded json directly into the body parameter

注意:此请求选项不支持自定义内容类型 标头或PHP的json_encode()函数中的任何选项.如果你 需要自定义这些设置,那么您必须传递JSON编码 您可以使用body request选项将数据输入到请求中,然后 必须使用标头请求指定正确的Content-Type标头 选项.

Note This request option does not support customizing the Content-Type header or any of the options from PHP's json_encode() function. If you need to customize these settings, then you must pass the JSON encoded data into the request yourself using the body request option and you must specify the correct Content-Type header using the headers request option.

此选项不能与body,form_params或multipart一起使用

This option cannot be used with body, form_params, or multipart