PRADHAN-P / php-twitter

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

twitter::followUser failure solution #25

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
twitter::followUser fails even after casting to type is removed and
although it counts towards the API call limit for the hour it does not do
anything. This is because the API requires that you use POST even though
there is nothing to post (as such). The quickest cure is to change the
default (optional) second value of twitter::process in the return value of
twitter::followUser to true (enough to pass the logical test but not pass
anything unneeded.

Thus:

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

This works for me.

My function now looks like this:

    /**
     * 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';
          echo $request, "\n";  
        return $this->objectify( $this->process($request, true) );
    }

Original issue reported on code.google.com by matt...@thanetstar.com on 24 Mar 2009 at 1:27

GoogleCodeExporter commented 9 years ago

Original comment by emmenset...@gmail.com on 24 Mar 2009 at 1:43

GoogleCodeExporter commented 9 years ago
man

It took me two hours to find this post!

Thank you so much

I just regretted I didn't see this earlier!

Peter from http://www.dealsvista.com

Original comment by sh.z...@gmail.com on 3 May 2009 at 4:42