我已编写此代码以获取关注者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];
}];
}
帐户参数取自ACAccountStore并且为非null但我得到一个空响应 - responseData包含0个字节。这曾经在几个星期前工作,所以我不明白问题是什么。有什么建议吗?
答案 0 :(得分:0)
问题在于网址。它需要使用https而不是http协议。