简体   繁体   English

PHP Curl发布带有非英语字符

[英]PHP Curl post with non-english characters

I have a small problem with php curl post. php curl post有一个小问题。

I am trying to post some turkish characters to a forum but aren't posted how it should be. 我正在尝试将一些土耳其字符发布到论坛上,但没有发布应该如何显示。

This is how i save the text: 这是我保存文本的方式:

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

and posting: 和发布:

$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 );

this is how it should be: 这应该是这样的:

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

this is how it is posted: 它是这样发布的:

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

Thanks 谢谢

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

Try adding: 尝试添加:

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

application/x-www-form-urlencoded suggested by @spencercw @spencercw建议的application/x-www-form-urlencoded

固定于

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM