SalmanAzmat / php-twitter

Automatically exported from code.google.com/p/php-twitter
0 stars 0 forks source link

Quote leading @ in status text. #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try to send a status like "@user text" via twitter::update()

What is the expected output? What do you see instead?
cURL comlains "failed creating formpost data".
Instead the message should be sent ;)

What version of the product are you using? On what operating system?
1.1

Please provide any additional information below.
I added a check for a leading '@' that replaces it by '\@'.

    function update( $status, $replying_to = false )
    {
        if( !in_array( $this->type, array( 'xml','json' ) ) )
            return false;

        if (substr($status, 0, 1) === '@')
        {
            $status = str_replace('@', '\@', $status);
        }

    $request = 'http://twitter.com/statuses/update.' . $this->type;
        //$status = $this->shorturl($status);
        $postargs = array( 'status' => $status );

    var_dump($request);

        if( $replying_to )
            $postargs['in_reply_to_status_id'] = (int) $replying_to; 

        var_dump($postargs);

        return $this->objectify( $this->process($request, $postargs) );
    }

See http://objectmix.com/php/499124-curl-sending-post-first-char.html

PS. Sorry, WinMerge died on me, so no real patch ;)

Original issue reported on code.google.com by saschaacarlin on 29 Apr 2009 at 12:51

GoogleCodeExporter commented 8 years ago
Scratch that. My fault.

What really fixed my problem is the following patch.

Original comment by saschaacarlin on 4 May 2009 at 3:32

Attachments:

GoogleCodeExporter commented 8 years ago
    if( !in_array( $this->type, array( 'xml','json' ) ) )
            return false;

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

        if( $replying_to ) :
            $postargs = 'status=' . rawurlencode($status) . '&in_reply_to_status_id=' . 
rawurlencode($replying_to);
        else :
            $postargs = 'status=' . rawurlencode($status);
        endif;

        return $this->objectify( $this->process( $request, $postargs ) );

Original comment by three.e...@gmail.com on 19 May 2009 at 2:55

GoogleCodeExporter commented 8 years ago
r100 fixes trunk and r99 fixes branches/1.1

Original comment by emmenset...@gmail.com on 16 Jun 2009 at 6:07

GoogleCodeExporter commented 8 years ago
Call me stupid but applying the fix causes this:

Warning: Invalid argument supplied for foreach() in
/www/htdocs/twitter/classes/class.twitter.php on line 718

The line in question is:
>>  foreach($postargs as $key => $value)

Original comment by dien...@gmail.com on 29 Jun 2009 at 7:57