【发布时间】:2017-01-30 14:59:27
【问题描述】:
让我们从例子开始。
如果我有固定的表单参数(姓名、电子邮件、电话),那么 Guzzle Post 方法代码将是这样的:
public function test(Request $request){
$client = new \GuzzleHttp\Client();
$url = www.example.com
$res = $client->post($url.'/article',[
'headers' => ['Content-Type' => 'multipart/form-data'],
'body' => json_encode([
'name' => $request['name'],
'email' => $request['email'],
'write_article' => $request['article'],
'phone' => $request['phone'],
])
]);
}
以上代码运行良好。
但是当没有固定的表单参数时,如何使用 Guzzle 发送数据?
我第一次提交表单时的例子,我有 name , email , phone 字段。下一次可能是 name、email、phone、father_name、mother_name、interest 等字段。。下次可能是 姓名、电子邮件、父亲姓名
那么如何处理这种动态表单域的情况呢?
【问题讨论】:
标签: php httpclient guzzle