Twitter API : How to get a list of users that a Tw

2019-08-12 23:00发布

问题:

I'm wondering if I'm allowed to get a list of friends that a twitter's user follow (following list) through MGTwitterEngine for Obj-C ?

If it's possible, please direct me how to do it Thanks

回答1:

You're allowed. MGTwitterEngine has sample code for their methods in AppController.m. This is the method for retrieving a list of who anyone is following.

[twitterEngine getFriendIDsFor:@"username_here" startingFromCursor:-1]


回答2:

ADD this to MGTwitterEngine.h along with followers methods

- (NSString *)getFollowingIncludingCurrentStatus:(BOOL)flag;

AND this to MGTwitterEngine.m along with followers methods

- (NSString *)getFollowingIncludingCurrentStatus:(BOOL)flag
{
    NSString *path = [NSString stringWithFormat:@"statuses/friends.%@", API_FORMAT];

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
    if (!flag) {
        [params setObject:@"true" forKey:@"lite"]; // slightly bizarre, but correct.
    }

    return [self _sendRequestWithMethod:nil path:path queryParameters:params body:nil 
                            requestType:MGTwitterFollowedTimelineRequest
                           responseType:MGTwitterUsers];
}