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,177
  • 3
  • 33
  • 47
Eray
  • 6,897
  • 15
  • 65
  • 118

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
  • 2,764
  • 17
  • 30
2

Probably on 32-bit servers.

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

Halcyon
  • 56,029
  • 10
  • 87
  • 125
1

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

Headshota
  • 20,343
  • 11
  • 58
  • 79