1
/* returns tweetDetails */
function returnTweets()
{
    $return = array();
    $url = $hashtagSearchUrl = "http://search.twitter.com/search.json?q=%23gencsengeleceksin&include_entities=1&result_type=recent&rpp=50";
    foreach(json_decode(file_get_contents($url))->results as $t)
    {
        $return[] = $t;
    }

    return $return;
}

/* assigns tweet details to a variable */
$ts = returnTweets();

foreach ($ts as $t)
    echo $t->id."<br />";

This must output a list of tweet id's . For example :

190914827918857531
190914827918845655
165456467265456156

Generally it's working but at some servers it's returning something like this:

1.9090219393785E+17

How can i solve this problem?

mskfisher
  • 3,291
  • 4
  • 35
  • 48
Eray
  • 7,038
  • 16
  • 70
  • 120

3 Answers3

3

You need to use id_str instead of id. 32-bit PHP (which is what most people have installed) cannot handle integers larger than 32 bits.

https://dev.twitter.com/docs/twitter-ids-json-and-snowflake

aknosis
  • 3,602
  • 20
  • 33
2

Probably on 32-bit servers.

Get the property id_str instead of id which will always be a string.

Halcyon
  • 57,230
  • 10
  • 89
  • 128
1

size of integers depend on the platform. you should probably use strings instead of numbers to manipulate that data.

Headshota
  • 21,021
  • 11
  • 61
  • 82