PHP Curl发布非英文字符

时间:2012-02-25 15:44:51

标签: php post curl utf-8

php curl post有一个小问题。

我试图将一些土耳其字符发布到论坛,但不会发布它应该如何。

这就是我保存文字的方式:


    fwrite($fpp,"\xEF\xBB\xBF");
    fwrite($fpp, $row['template']);
    fclose($fpp);

并发布:     

$this->curl = curl_init();
    curl_setopt ( $this->curl, CURLOPT_URL, $this->vb_url . 'newthread.php?' . $url_vars );
    curl_setopt ( $this->curl, CURLOPT_POST, true );
    curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
    curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
    curl_setopt ( $this->curl, CURLOPT_CONNECTTIMEOUT,20);
    curl_setopt ( $this->curl, CURLOPT_TIMEOUT,10);
    curl_setopt ( $this->curl, CURLOPT_HEADER, true );
    curl_setopt ( $this->curl, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
    curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
    curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
    curl_setopt ( $this->curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1;    en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
   $result = curl_exec ( $this->curl );

这应该是这样的:

{{1}}

这就是它的发布方式:

`Bölüm resimleri, dizi indirme ve altyazı linkine aşağıdan ulaşabilirsiniz.` 

由于

2 个答案:

答案 0 :(得分:2)

来自http://php.net/manual/es/function.curl-setopt.php

尝试添加:

curl_setopt($this->curl,CURLOPT_HTTPHEADER,array (
    "Content-Type: application/x-www-form-urlencoded; charset=utf-8"
));
@spencercw建议

application/x-www-form-urlencoded

答案 1 :(得分:2)

已修复

$message = @iconv("UTF-8","Windows-1252//IGNORE",$message);