Can I use TwitterKit for the Streaming APIs?


#1

I’m trying to access User streams, say a load of tweets that include the word “bike”, but I’m having no such luck. :frowning:
I’ve got TwitterKit set up in my Xcode (Objective C) project. I’m trying to call the stream sample as below, but I never get a response. Any help would be GREATLY appreciated:

NSString *statusesShowEndpoint = @"https://stream.twitter.com/1.1/statuses/sample.json";
NSDictionary *params = @{};
NSError *clientError;
NSURLRequest *request = [[[Twitter sharedInstance] APIClient]
                         URLRequestWithMethod:@"POST"
                         URL:statusesShowEndpoint
                         parameters:params
                         error:&clientError];

if (request) {
    [[[Twitter sharedInstance] APIClient]
     sendTwitterRequest:request
     completion:^(NSURLResponse *response,
                  NSData *data,
                  NSError *connectionError) {
         
         NSLog(@"response0 %@", response);

         if (data) {
             // handle the response data e.g.
             NSError *jsonError;
             NSDictionary *json = [NSJSONSerialization
                                   JSONObjectWithData:data
                                   options:0
                                   error:&jsonError];
             
             NSLog(@"json %@", json);
             NSLog(@"response1 %@", response);

         }
         else {
             NSLog(@"Error1: %@", connectionError);
             NSLog(@"response2 %@", response);

         }
     }];
}
else {
    NSLog(@"Error: %@", clientError);

}

P.s, i can use TwitterKit to get individual tweets based on IDs etc, so I do believe it is set up ok. And using the REST API also works, but I need streaming.


#2

I also have the same question, did you get any answer yet? Thank you.


#3

Can you share the full console output you’re getting when this is happening?