如何使用Fabric api显示来自特定用户的时间轴的推文。 这是我的代码,我试图在数组中加载tweety的ID,然后在表格视图中显示它们。
@implementation YourTweetViewController
- (void)viewDidLoad {
[super viewDidLoad];
[TwitterKit logInGuestWithCompletion:^(TWTRGuestSession *guestSession, NSError *error) {
if (guestSession) {
// Load tweets
__weak typeof(self) weakSelf = self;
NSArray *tweetIDs = @[@"20", // @jack's first Tweet
@"510908133917487104" // our favorite Bike tweet
];
[[[Twitter sharedInstance] APIClient] loadTweetsWithIDs:tweetIDs completion:^(NSArray *tweets, NSError *error) {
if (tweets) {
typeof(self) strongSelf = weakSelf;
strongSelf.tweets = tweets;
[strongSelf.tableView reloadData];
} else {
NSLog(@"Failed to load tweet: %@", [error localizedDescription]);
}
}];
} else {
NSLog(@"Unable to log in as guest: %@", [error localizedDescription]);
}
}];
}
答案 0 :(得分:1)
Twitter Kit 1.5.0支持时间轴:
import UIKit
import TwitterKit
class ViewController: TWTRTimelineViewController {
convenience init() {
let client = Twitter.sharedInstance().APIClient
let dataSource = TWTRUserTimelineDataSource(screenName: "fabric", APIClient: client)
self.init(dataSource: dataSource)
}
override required init(dataSource: TWTRTimelineDataSource) {
super.init(dataSource: dataSource)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
答案 1 :(得分:0)
使用TwitterKit无法显示用户的所有推文(不知道推文的ID)。您必须使用Twitter Api v1.1实现您的自定义解决方案,并具有所有限制。
可以在此处找到Twitter REST Api的完整参考:https://dev.twitter.com/rest/public