Search code examples
iosswifttwittertwitter-oauth

Load twitter posts from different users


Hi need to load twitter posts from different users. I know how to load post from single user. Perform request with search query FROM:<username>. Do you know the way how to load posts from different users? I tried something like this FROM:<username1>&&<username2> - but it doesn't work. Any ideas?


Solution

  • I found an approach. I have to use Twitter iOS SDK and TWTRAPIClient for performing the request. https://api.twitter.com/1.1/statuses/user_timeline.json is endpoint for getting tweets of certain user with some username.

      NSURLRequest *r = [[TWTRAPIClient new] URLRequestWithMethod:@"GET"
                                                                    URL:@"https://api.twitter.com/1.1/statuses/user_timeline.json"
                                                             parameters:@{@"screen_name":name}
                                                                  error:nil];
    
    
            [[TWTRAPIClient new] sendTwitterRequest:r completion:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
                if(data){
    
                    NSArray *tweets = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
                    [TWTRTweet tweetsWithJSONArray:tweets]
    
    
                }
            }];