View Full Version : Twitter Links Broken

16 Aug 2011, 11:43 AM
Hi there,

I'm building an app based on the O'Reilly Conference app example shipped with Sencha Touch. The Tweet Store is loading properly, but the links to the tweets within twitter.com are broken.

The behaviour can be seen in the O'Reilly Conference App example. Load it, and go to the Twitter panel. Now click one of the tweets. It asks if you want to open it in twitter.com. Click yes, and you will (most likely) be taken to a "Sorry, that page doesn't exist" page.

As far as I can tell, it's because the tweet id is getting rounded when it goes into the store. For example, a tweet id that comes in from the twitter feed as 103551456984051712 gets stored as 103551456984051710 (note the least significant digit).

I'm baffled and don't know where to start. Has anyone else seen/solved this issue?

Trevor Mills

18 Aug 2011, 12:33 PM
I still don't know why it appears that the ID gets rounded, but I've figured out a workaround. The Twitter API actually sends back both an `id` and an `id_str` parameter. They contain the same value. Sencha seems to mangle `id`, but thankfully `id_str` is left unchanged. The workaround then involves two simple things:

1) Add `id_str` to the Tweet Model
2) Update how the window.location string gets built when opening the tweet in a new window

Working from the O'Reilly Conference App sample app, I had to modify two files:

I modified examples/oreilly/src/Models.js, changing line 28 from:

fields: ['id', 'text', 'to_user_id', 'from_user', 'created_at', 'profile_image_url']


fields: ['id', 'id_str', 'text', 'to_user_id', 'from_user', 'created_at', 'profile_image_url']

Then, I modified examples/oreilly/src/TweetList.js, changing line 71 from:

window.location = 'http://twitter.com/' + records[0].data.from_user + '/status/' + records[0].data.id


window.location = 'http://twitter.com/' + records[0].data.from_user + '/status/' + records[0].data.id_str

Hope someone else finds this helpful.