【问题标题】:someone please tell me how to get a list of twitter friends handles @twitter in iOS有人请告诉我如何在 iOS 中获取 Twitter 好友句柄 @twitter 的列表
【发布时间】:2014-01-19 15:20:55
【问题描述】:
NSURL *followingURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/lists/list.json"];

NSDictionary *parameters= [NSDictionary dictionaryWithObjectsAndKeys:account.username,@"screen_name", nil];


SLRequest *twitterRequest =[SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:followingURL parameters:parameters];

[twitterRequest setAccount:account];

[twitterRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
    if (error) {
        //DEAL WITH THE ERROR
    }
    NSError *jsonError =nil;
    NSDictionary *twitterFriends = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONWritingPrettyPrinted error:&jsonError];


    [accountDictionary setObject:[twitterFriends objectForKey:@"screen_name"] forKey:@"screen_name"];
    NSLog(@"%@", accountDictionary);    }
 ];

我正在使用此代码,但我的应用程序崩溃了。所以任何进一步的帮助将不胜感激

【问题讨论】:

  • 如果你告诉它崩溃的位置和方式会更有帮助。

标签: ios iphone objective-c twitter


【解决方案1】:

您可以将此组件用作基础。 https://github.com/ArchieGoodwin/NWTwitterHelper

使用 twitter 用户名(screen_name)从 twitter 中获取朋友:

 [[twitterHelper sharedInstance] getFollowers:@"screen_name" completionBlock:^(BOOL result, NSError *error) {
            //here is code
 }];

您将在 ((twitterHelper *)[twitterHelper sharedInstance]).stringFriends 中获得一个包含好友 user_id、name、screen_name、profile_image_url 的示例 NSString

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-11
    • 2013-06-22
    • 1970-01-01
    • 1970-01-01
    • 2015-04-05
    • 1970-01-01
    • 2011-12-12
    相关资源
    最近更新 更多