2

I would like to make a search query using the geolocalization parameter allowed through the Twitter API:

I am using TwitterKit from Fabric iOS to display a search timeline like so:

TWTRSearchTimelineDataSource *searchTimelineDataSource = 
    [[TWTRSearchTimelineDataSource alloc] initWithSearchQuery:searchTerm 
                                                    APIClient:APIClient];

https://docs.fabric.io/ios/twitter/show-timelines.html.

Unfortunately, if you look at the TWTRTimelineDataSource.h header file, there is a comment that says:

Not implemented: geocode, result_type

Even though the Twitter API documentation warns us that the 'near' operator isn't available, I tried the "near:within:" parameters (e.g., searchTerm = @"Apple near:NYC within:100mi"), since according to the Fabric docs, searchTerm in this case is exactly "the query string that you would type into https://twitter.com/search". As expected, you get back an error:

[TwitterKit] Couldn't load tweets from TWTRTimelineViewController:...
{NSErrorFailingURLKey=https://api.twitter.com/1.1/search/tweets.json?count=30&result_type=filtered&q=%23AppleEvent%20near%3ANYC%20within%3A100mi%20-filter%3Aretweets, 
NSLocalizedDescription=Request failed: bad request (400), 
NSLocalizedFailureReason=Twitter API error : near parameter is invalid. (code 44)}

I can't find the actual source code for TWTRTimelineDataSource.m anywhere, so I don't think I am able to subclass it in order to add the geocode query capability myself. Is there any other way I could still use the built-in TWTRTimelineViewController with a geolocation query?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.