TWTRClient URLRequestWithMethod returns null

ios

#1

I’m using the sample Objective-C code found here to try to send a GET statuses/user_timeline request in an iOS application. However, when I call [client URLRequestWithMethod] it returns a null NSURLRequest. The error parameter I pass in isn’t getting filled with anything, so nothing is happening there. I’ve tried formatting my own request using Apple’s NSURLRequest methods, but when I pass that into [client sendURLRequest] I get radio silence…not even an error response. My code is below (“screenName” is a variable that I have checked for correctness). What can I do to resolve this issue?

    NSString *reqString = @"https://api.twitter.com/1.1/statuses/user_timeline.json";
    NSDictionary *params = @{@"screen_name" : screenName, @"count" : @"200"};
    NSError *clientError;
    NSURLRequest *request = [self.twitterClient URLRequestWithMethod:@"GET" URL:reqString parameters:params error:&clientError];

    if(clientError){
        NSLog(@"Client error: %@", clientError);
    }
    
    NSLog(@"URL Request: %@", request);
    
    // fire away
    [self.twitterClient sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        if (data) {
            // handle the response data e.g.
            NSLog(@"Got response!");
            NSError *jsonError;
            NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
            NSLog(@"%@", json);
        }
        else {
            NSLog(@"Error: %@", connectionError);
        }
    }];

#2

@papa_rosh Great to hear from you! Have you followed the steps over here: https://docs.fabric.io/ios/twitter/show-tweets.html. Can you let me know if you are able to get Tweets to show in your app with that sample code. Thanks!


#3

Thanks for replying. I’m trying to get x number of tweets from a user given a screen name (assuming their account is public) so it seemed to me that those wouldn’t be useful for me. However, I tried using that sample code just to see if it worked and got a similar problem: no response whatsoever. It did occur to me that I might need to set App Transport Security permissions in my .plist file, as this sometimes messes with HTTP requests in the iOS Simulator, but doing that didn’t affect this in any way. So I’m still stuck, unfortunately.