Reputation: 8336
I'm trying to display my last tweets with the twitter api on my website. I've included the following function (I use jQuery):
function render(o) {
for(var i = 0; i < 5; i++){
$('.section').append('<a target="_blank" href="http://twitter.com/mytwittername/status/' + o[i].id + '">' + o[i].text + '</a><br /><hr /><br />');
}
}
After that I include the json file with the callback:
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/mytwittername?
callback=render"></script>
It all works kinda fine. The content of the tweets is correct. But the ID isn't. The ID is correct, except the last digit is always a 0, but actually it is another number. In the source code of the json file the ID is the right one. Am I doing something wrong?
Upvotes: 1
Views: 461
Reputation: 6284
Try to parse out id_str attribute instead. JS doesn't support 64bit numbers as far as I know. So Twitter returns string representation.
Details here: http://groups.google.com/group/twitter-api-announce/browse_thread/thread/6a16efa375532182?pli=1 or there http://hustoknow.blogspot.com/2011/02/twitters-idstr.html
Upvotes: 1