0

我编写了这段代码来获取关注者的 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 个字节。这曾经在几周前起作用,所以我看不出问题出在哪里。有什么建议么?

4

1 回答 1

0

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

于 2014-02-20T14:07:27.777 回答