【问题标题】:iOS Twitter API returns no followersiOS Twitter API 不返回任何关注者
【发布时间】:2014-02-19 14:51:19
【问题描述】:

我已经编写了这段代码来获取关注者的 ID 列表:

+ (void)getTwitterFriendsIDListForAccount:(ACAccount *)account withHandler:(TWFriendsListHandler)handler
{
    NSMutableString *paramString = [[NSMutableString alloc] init];
    NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1.1/followers/ids.json"];
    NSDictionary *params = @{@"screen_name" : account.username};

    SLRequest *twRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter
                                              requestMethod:SLRequestMethodGET
                                                        URL:url
                                                 parameters:params];
    [twRequest setAccount:account];
    [twRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        if (error) {
            handler(nil, error);
        }

        NSError *jsonError = nil;
        NSDictionary *twitterFriends = [NSJSONSerialization JSONObjectWithData:responseData
                                                                       options:NSJSONWritingPrettyPrinted
                                                                         error:&jsonError];
        NSArray *IDlist = [twitterFriends objectForKey:@"ids"];
        int count = IDlist.count;
        for (int i = 0; i < count; i++) {
            [paramString appendFormat:@"%@", [IDlist objectAtIndex:i]];
            if (i < count - 1) {
                NSString *delimeter = @",";
                [paramString appendString:delimeter];
            }
        }
        [self getFollowerNameFromID:paramString forAccount:account withHandler:handler];
    }];
}

account 参数取自 ACAccountStore 并且不为空,但我得到一个空响应 - responseData 包含 0 个字节。这曾经在几周前起作用,所以我看不出问题出在哪里。有什么建议吗?

【问题讨论】:

    标签: ios twitter twitter-follow


    【解决方案1】:

    问题出在网址上。它需要使用https而不是http协议。

    【讨论】:

      猜你喜欢
      • 2012-08-07
      • 1970-01-01
      • 1970-01-01
      • 2012-07-20
      • 2013-07-01
      • 1970-01-01
      • 2010-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多