我正在接收来自POST的数据,现在我想使用curl转发此数据。
问题是我的代码不会发布像ÅÄÖ这样的特殊字符。它们包含在$ postdata中,但是当我查看接收服务器时,缺少特殊字符。
有没有更好的方法为cUrl准备数据?像预建的funktion? 我如何包括ÅÄÖ:s?
以下是代码:
foreach ($_POST as $var => $value) {
if ($var != "ignore") {
$postdata=$postdata . urlencode(str_replace("_", "." , $var)) . "=" . $value . "&";
}
}
//remove the extra comma
$postdata=substr($postdata,0,-1);
//Submit the form fields
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,$googleformURL);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$data = curl_exec ($ch);
curl_close($ch);