2009/7/8 AlexanderZn <alexan...@liljengard.se>: > > Hi all! > > I'm writing a twitter-widgets that is based on data formated as JSON. > I get the data from > http://twitter.com/statuses/user_timeline.json?screen_name=username > > Locally this works like a charm, but when i upload the script to my > webserver i get negative ids. > > [id] => -1766397267 > instead of, > [id] => 2528570029 > > I get the data with file_get_contents() and turn it into an array with > json_decode($jsondata,true) with php.. > > Does anybody have a clue why it is like this?
You're running on 32-bits and json_decode treats numbers it gets as numbers, so when converted to a signed 32-bit int it becomes negative. The easiest solution is to use the pear package Services_JSON instead of json_decode and ensure your code never treats the ID as a number. The better solution is to move to 64-bit but obviously that may involve changing hardware so might not be feasible for you. -Stuart -- http://stut.net/projects/twitter/