views:

327

answers:

1

Elliot Haughin wrote a lovely library for using the twitter api

I got it up and running smoothly but I have an issue when using paged requests (cursors), for instance in statuses/friends.

If I do this:

$test = $this->twitter->call(’statuses/friends’, array(’id’ => ‘dennis_decoene’, ‘cursor’=>’-1′));
echo $test->next_cursor;

I get “1.32215833937E+18″ for example. If I supply this to the next call to get the next 100 users, I get an error. If I do a print_r($test) on the second call, this is printed:

stdClass Object
(
    [users] => Array
        (
        )

    [next_cursor] => 0
    [previous_cursor] => 0
)

It is empty, because the cursor value is fubar…

How can I get/supply the correct next cursor value?

+2  A: 

I found an answer: number_format, see the following code, this works correctly:

$test = $this->twitter->call('statuses/friends', array('id' => 'dennis_decoene', 'cursor'=>'-1'));
$next_cursor = number_format($test->next_cursor, 0, '.', '');

echo $next_cursor;

If I supply $next_cursor to a new call, I get the intended behaviour.

Dennis Decoene