Hi there !

i'm trying to configure a twitter scheduled script and i having
problem to send accented char !
I know that i have to encode and utf8 encode before sending, and I do
it :
$status = urlencode(utf8_encode($status));

my request :
http://twitter.com/statuses/update
I'm using curl

The problem is that  it is sending well the encoded value, but it
appears encoded on twitter...

here my code :
        public function update( $status, $url = NULL, $replying_to = false )
        {
                $status = urlencode(utf8_encode($status));
            if( !in_array( $this->type, array( 'xml','json' ) ) )
                return false;

        $request = 'http://twitter.com/statuses/update.' . $this-
>type;

                // If the status is more than 117 chars, it cut them
                $status = $this->_cut($status);

                // If a url is sent with the status, it go through a shorting 
url
service
                if( $url )      $shorturl = $this->_shorturl($url);

        $postargs = array( 'status' => urlencode(utf8_encode($status.
$shorturl)) );
        if( $replying_to )
            $postargs['in_reply_to_status_id'] = (int) $replying_to;

                return $this->_objectify( $this->_process($request, $postargs) 
);
        }

private function _process($url,$postargs=false)
        {
            $url = ( $this->suppress_response_code ) ? $url .
'&suppress_response_code=true' : $url;
                $ch = curl_init($url);
                if($postargs !== false)
                {
                        curl_setopt ($ch, CURLOPT_POST, true);
                        curl_setopt ($ch, CURLOPT_POSTFIELDS,$postargs);
        }

                if($this->_username !== false && $this->_password !== false)
                        curl_setopt($ch, CURLOPT_USERPWD, 
$this->_username.':'.$this-
>_password );

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_NOBODY, 0);
        if( $this->debug ) :
            curl_setopt($ch, CURLOPT_HEADER, true);
        else :
            curl_setopt($ch, CURLOPT_HEADER, false);
        endif;
        curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);

        $response = curl_exec($ch);

        $this->responseInfo=curl_getinfo($ch);
        curl_close($ch);


        if( $this->debug ) :
            $debug = preg_split("#\n\s*\n|\r\n\s*\r\n#m", $response);
            echo'<pre>' . $debug[0] . '</pre>'; exit;
        endif;

        if( intval( $this->responseInfo['http_code'] ) == 200 )
                        return $response;
        else
            return false;
        }

Reply via email to