我想将 Twitter 集成到我的 iPhone 应用程序中,以获取特定 Twitter 帐户的一些推文。请给我建议最好的主意?
注意:
我只想显示来自特定帐户的推文。任意短 方法将有助于完整而不是完整的 Twitter 集成
目前我正在使用 RSS 来获取推文,但我在某处听说过 RSS 推特提要非常不可靠,它们将会停止 即将支持 RSS。
如果您不想使用完整的实现,您只需要对特定用户的状态执行查询 例如,使用 ASIHTTPRequest 获取 charliesheen 的最后 20 条推文
NSURL *url = [NSURL URLWithString:@"http://twitter.com/statuses/user_timeline/charliesheen.xml"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
- (void)requestFinished:(ASIHTTPRequest *)request {
// this is called if the request is successful
}
- (void)requestFailed:(ASIHTTPRequest *)request {
// this is called if the request fails
}
如果不想用xml,改成json即可
http://twitter.com/statuses/user_timeline/charliesheen.json
https://github.com/jaanus/PlainOAuth/tree/27a8631a5e32c36ea40d532c8343fafe7cc5e95c 并下载源项目..
此链接为您提供最近五条推文..
得到答案了。 - 我将 MGTwitterEngine 添加到我的项目中。
这里是代码:[MyViewController's -(void)viewDidLoad]-
MGTwitterEngine *twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
[twitterEngine getUserTimelineFor:username sinceID:0 startingAtPage:0 count:10];
如果你们需要更多说明,请随时询问。我会尽力帮助你。
问候!!