1
votes

I've been struggling to migrate from twitter v1 to v1.1 in my iOS application. What I need to do is probably the simplest thing, pull a specific twitter user's last 5 tweets. With v1 I just used the open API, but with v1.1 I need to authenticate. I don't want to have to rely on the iPhone user to have the universal login setup, so I've been researching Application Only Authentication.

Does anyone have an example of how to implement this on iOS? I've been reading the twitter documentation here https://dev.twitter.com/docs/auth/application-only-auth and there aren't specific examples.

Thanks for the help.

2

2 Answers

3
votes

Check this library out

https://github.com/nst/STTwitter

One of the many methods the library has:

- (void)getUserTimelineWithScreenName:(NSString *)screenName
                         successBlock:(void(^)(NSArray *statuses))successBlock
                           errorBlock:(void(^)(NSError *error))errorBlock;

Oh, and it works with the new version of the API (1.1)

1
votes

The new Twitter APIs suck for a reason: they are actively discouraging any third-party apps.

At this point, the safe bet is probably just to use something similar to wget, a decent user agent, and --no-check-certificate ... if they wanted people to use the API, they shouldn't have yanked it out from under everyone.

wget --no-check-certificate https://twitter.com/zaphraud

Not sure what the iOS equivalent to wget is, but there doubtless is something.

Will return my last 5+ tweets and a bunch of HTML garbage that you will have to prune out. Once upon a time, the API was easy. But not any more! Stripping HTML is probably easier than safely implementing cryptographic protocols according to an API designed to strongly discourage ANY third-party involvement in the first place (Twitter's new business plan). This is why third-party image hosts are having such difficulty with Twitter, Inc these days. Etc...

Twitter is breaking compatibility even with their OWN Twitter 3.x clients that are less than a year old. Are you ready to write code that will die in under a year due to bureaucratic whim?

Remember: If it can show on the screen, it can be scraped. You don't HAVE to do it THEIR way.