jacquagnui / php-twitter

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

directMessages() arguments and syntax #33

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The argument list in the implementation of directMessages($since, $count, 
$since_id, $page) 
doesn't match the current API argument list ($since_id, $max_id, $count, 
$page). 

Whilst the argument list includes $count, no provision is made for collecting 
any specified 
argument in the $qsparams array(), so is not passed into the request.

In the $request build, the $qsparams array() is tacked immediately onto the end 
of the url without 
insertion of the requisite '?' resulting in a bum call to the api.

Original issue reported on code.google.com by three.e...@gmail.com on 21 May 2009 at 1:07

GoogleCodeExporter commented 8 years ago
This oughta work, I note the $qs is present, contains the ? but hasn't been 
added to the request build...

    function directMessages( $since_id = false, $max_id = false, $count = null, $page = false )
    {
        if( !in_array( $this->type, array( 'xml','json','rss','atom' ) ) )
            return false;

        $qs='?'; // here's our little fella! (note he exists but hasn't been included)

        $qsparams = array();
        if( $since_id )
            $qsparams['since_id'] = (int) $since_id;
        if( $max_id )
            $qsparams['max_id'] = (int) $max_id;
        if( $count )
            $qsparams['count'] = (int) $count;
        if( $page )
            $qsparams['page'] = (int) $page;

        $request = 'http://twitter.com/direct_messages.' . $this->type . $qs . implode( '&', $qsparams );

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

Original comment by three.e...@gmail.com on 21 May 2009 at 1:12

GoogleCodeExporter commented 8 years ago
$this->_glue() is the internal method that creates proper query strings. :) 
r102 fixes. Thanks

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