Gig提供Twitter 1.1 API的异步块封装Objective-C包装器。它使用Mantle来模型化Twitter平台对象,并使用AFNetworking来执行API请求。
Gig仍在进行中。已经完全实现了Tweets、Users、Entities和Places的模型。至于API,Gig目前实现了时间线和与推文相关的方法。其余的方法将在以后的时间内实现(欢迎pull requests!)。
Gig使用Accounts Framework来认证API请求。只需使用一个ACAccount
对象来初始化您的客户端,所有请求都将使用该账户签名。
GIGClient *client = [[GIGClient alloc] initWithAccount:account];
使用-fetchTimeline:parameters:completion
方法从Twitter时间线获取推文。
// Fetch the two most recent tweets in my home timeline
[client fetchTimeline:GIGTimelineHome parameters:@{
GIGCountKey : @2
} completion:^(NSArray *tweets, NSError *error) {
for (GIGTweet *tweet in tweets) {
NSLog(@"%@: %@", tweet.user.screenName, tweet.text);
}
}];
// Update status
[client updateStatusWithText:@"Hello world!!!" parameters:nil completion:^(GIGTweet *tweet, NSError *error) {
NSLog(@"statusID: %@", tweet.statusID);
}];
// Update status with media
NSData *data = UIImageJPEGRepresentation(picture, 1.0);
[client updateStatusWithText:@"Hello world!!!" media:data parameters:nil completion:^(GIGTweet *tweet, NSError *error) {
GIGMedia *media = tweet.entities.media[0];
NSLog(@"statusID: %@, mediaID: %@", tweet.statusID, media.mediaID);
}];
Guillermo Gonzalez
@gonzalezreal
Gig遵循MIT许可证发布。请参阅LICENSE.md。