我在使用 curl 时遇到问题:我从 Mysql(城市名称)获取数据,这些数据使用 ascii HEX 编码的变音符号(例如 %DF 表示 ß 或 %DC 表示 ü )。我用 str_replace() 转换它们;到德语变音符号 (ß,ü,ä,ö)。当我使用 curl 发送数据(城市)时出现错误。(“填写正确的!”)
当我发送没有变音符号(ä、ö、ü、ß)的数据时,一切都很好!我的代码或 curl 有什么问题。我也用 shell 试过了——同样的问题!
$this->url = "blah.org/?params=diesdas&city_from=Straßbourg&City_to=München";
$this->ckfile = tempnam("/tmp", "cookie");
$this->ch = curl_init();
curl_setopt($this->ch,CURLOPT_URL, $this->url);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($this->ch, CURLOPT_PROXY, "46.4.248.80");
curl_setopt($this->ch, CURLOPT_PROXYPORT, "3128");
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->ckfile);
echo 'getting cookie file...';
$cookie = curl_exec($this->ch);
if($cookie = false){echo 'couldn\'t get cookie!<br> '.curl_error($this->ch);}else{echo 'got cookie! omnomnom!<br>';}
$this->ch = curl_init("blah.com/sendcookietome");
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->ckfile);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($this->ch, CURLOPT_PROXY, "46.4.248.80");
curl_setopt($this->ch, CURLOPT_PROXYPORT, "3128");
curl_exec($this->ch);
最好的,meeeeh!