Twitter sure handles a lot of messages

Been battling some Twitter code I wrote a few months ago that first posts a status update to a Twitter account using /statuses/update.json, then allows a user to retweet using /statuses/retweet/[tweetMessageId].json to another Twitter account.

When I tried the routine this morning it steadfastly refused to send the re-tweet. The Twitter api just returned 'Not Found'.

I tore all the routines apart, added debugs everywhere, without success. Then, staring at the returned JSON values, with the database open on another screen, I finally twigged.

When I post the Tweet I'm grabbing the message ID number and saving that to the database. Then, when I want to retweet, I use that message id in the retweet end point.

A couple of months ago the message Ids were 11 digits long, now they are 16 digits. I'd been grabbing the 'id' value coming back from Twitter, but a number that long was getting truncated by my JSON parse routine (I'm using the very handy JSON2 library). I checked the JSON values and Twitter very kindly also sends back 'id_str', which is the message id as a string. For example the JSON contained:

"id":1436631697457152

"id_str":"1436631697457152"

Indeed, now I look more closely, I can see that they also send back the ID of the Twitter account using the same, for example:

"id_str":"112303018"

I guess the explosion in the message Id in the past few months just continues to underscore the remarkable growth in Twitter's scale, presuming the message ID values have simply been incrementing sequentially over that time and haven't been jumped ahead manually for some reason.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s