通过php发送url编码数据时出错

通过php发送url编码数据时出错,php,post,curl,Php,Post,Curl,以下是我的CURL post php代码: $post = array("field1"=>"data1%%Fval","field2"=>"data2%%12 Add"); $fields = ""; $i = 0; foreach ($post as $key => $value) { $fields .= ($i > 0) ? "&" . "$key=" . urlencode($value) : "$key=" . urlencode($valu

以下是我的CURL post php代码:

$post = array("field1"=>"data1%%Fval","field2"=>"data2%%12 Add");

$fields = "";

$i = 0;
foreach ($post as $key => $value) {
$fields .= ($i > 0) ? "&" . "$key=" . urlencode($value) : "$key=" .    urlencode($value);
$i++;
};

set_time_limit(60);
$output = array();
$curlSession = curl_init();
curl_setopt ($curlSession, CURLOPT_URL, $url);
curl_setopt($curlSession, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt ($curlSession, CURLOPT_POST, 1);
curl_setopt ($curlSession, CURLOPT_POSTFIELDS, $fields);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curlSession, CURLOPT_TIMEOUT,30);
curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 0);

$rawresponse = curl_exec($curlSession);
当我使用上述代码通过php CURL发布url编码的数据时,我不会在服务器端获取url编码的数据,在服务器端我以post的形式接收数据

我的代码似乎有任何问题,在发送数据之前自动执行URL解码


谁能告诉我这个问题的解决方法吗?

。。默认情况下,PHP将自动对
$\u POST、$\u GET和$\u REQUEST进行url解码是的,在读取参数时不需要对url进行解码。此外,也不需要对POST数据进行url编码。只需按原样将
$post
数组传递到
CURLOPT\u POSTFIELDS
选项