我正在基於Twitter的應用程序中,我想要獲取登錄的Twitter用戶的朋友列表。我已經爲此做了一個代碼,但它返回錯誤。如何在iPhone中獲取twitter用戶的好友列表?
NSMutableArray *arr = [[NSMutableArray alloc] init];
NSMutableDictionary *accountDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:account.username, @"screen_name", nil];
[accountDictionary setObject:[[[account dictionaryWithValuesForKeys:[NSArray arrayWithObject:@"properties"]] objectForKey:@"properties"] objectForKey:@"user_id"] forKey:@"user_id"];
NSURL *followingURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/1.1/friends/list.json?cursor=-1&screen_name=%@&skip_status=true&include_user_entities=false",account.username]];
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:account.username, @"screen_name", nil];
TWRequest *twitterRequest = [[TWRequest alloc] initWithURL:followingURL
parameters:parameters
requestMethod:TWRequestMethodGET];
[twitterRequest setAccount:account];
NSError *jsonError = nil;
NSData *responseData;
NSDictionary *twitterFriends = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONWritingPrettyPrinted error:&jsonError];
[accountDictionary setObject:[twitterFriends objectForKey:@"list"] forKey:@"friends_list"];
return arr;
我得到這個錯誤:
{ errors = ({ code = 34; message = "Sorry, that page does not exist"; }); }
可能是你應該在這裏張貼此錯誤??? – Stas
它給這個錯誤它不顯示朋友列表{ 誤差=( { 代碼= 34; 消息=「抱歉,該頁面不存在」; } ); } – Rani
你確定'followingUrl'以正確的方式組成嗎? – Stas