SalmanAzmat / php-twitter

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

Corrected of followUser #41

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. correct the int problem (remove the cast "(int)")
2. correct the "POST" problem, friendship/create require POST fields too, so I 
had there
see 
http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-friendships%C2%A0create?
SearchFor=create&sp=1 for more informations

This the new code, could you add this to the next release ?

    /**
     * Sends a request to follow a user specified by ID
     * @param integer|string $id The twitter ID or screenname of the user to follow
     * @param boolean $notifications Optional. If true, you will recieve notifications from the 
users updates
     * @return string
     */
    function followUser( $id, $notifications = false )
    {
        if( !in_array( $this->type, array( 'xml','json' ) ) )
            return false;

        $request = 'http://twitter.com/friendships/create/' . $id . '.' . $this->type;
        if( $notifications )
            $request .= '?follow=true';
        $postargs = array( 'id' => $id, 'follow' => $notifications);

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

Original issue reported on code.google.com by capri...@gmail.com on 12 Jul 2009 at 5:03

GoogleCodeExporter commented 8 years ago
I've tried all the different solutions for this and didn't have any luck. I 
used this
code and did what another user did here and put the section where the POST 
options is
set in process() right before the call to curl_exec():

http://code.google.com/p/php-twitter/issues/detail?id=36#c8

Calls to followUser() seem to work now.

Original comment by joe.fear...@gmail.com on 17 Feb 2010 at 1:36