[英]CURLOPT_POSTFIELDS encoding
我不确定使用 cURL 时使用什么编码:
得到:
邮政:
(POSTFIELDS=) 测试=测试 1
(POSTFIELDS=) 测试=测试+1
(POSTFIELDS=) 测试=测试%201
CURL 可以接受 arguments 的数组进行发布,它会为您处理编码:
$array = (
'test' => 'test 1',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $array);
但是,根据 curl 文档(http://php.net/curl_setopt,搜索 CURLOPT_POST_FIELDS),对于 PHP,这些对应为urlencode()
格式:
$post_args = urlencode('test=test 1');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_args);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.