php - 发送带有空表单数据字段的 POST 请求
问题描述
问题是当我想发送一个带有空表单数据字段的 POST 请求时,我没有从服务器得到正确的响应。我通过 POSTMAN 提出了这个请求,它工作正常。我需要发送空和非空表单数据字段的混合,如下所示:
email_add_text:
email_add_text2:
email_address:
email_address2:xxxx
email_count:20
email_count2:20
我测试了https://github.com/guzzle/guzzle/issues/973中提到的解决方案;但是,无论是空字符串还是空值,都不能在 guzzle 中工作。如何使用 guzzle 或 php 中的任何其他工具来做到这一点?
解决方案
After some investigation, I checked the query with the Postman's Console. The trick is that we should embrace all of keys and values into the single or double quotations. Thus, the form-data fields on the guzzle should be like this:
'form_params' =>
[
'email_add_text' => "",
'email_add_text2' => "",
'email_address' => "",
'email_address2' => "xxxx",
'email_count' => "20",
'email_count2' => "20"
]
推荐阅读
- c++ - async_write 完成处理程序最早何时完成?
- c++ - 使用完数据结构后清空它们是一个好习惯吗?
- java - 有/没有 TRUNCATE_EXISTING 的 StandardOpenOption.WRITE + StandardOpenOption.CREATE 之间的区别?
- .net - SPA 角色声明和授权。.net 核心和 react.js
- amazon-web-services - 如何使用 AWS 实例连接到本地计算机上的服务器?
- reactjs - React Bootstrap 3 - FormControl.Feedback 消息传递
- flutter - 为什么flutter的Future函数会运行多次?
- php - php while循环不在引导程序中水平打印数组的内容
- azure-functions - Azure REST API“listsecrets”为具有自定义路由的函数返回不正确的触发 URL
- reactjs - React 上下文提供程序中的意外令牌“<”