Reputation: 15464
In my iOS application I need to show user's tweets that contains a specific hashtag. In rest api 1.1 there is users/search
endpoint. But it believe it is not the one that is suitable for this. There is search/tweets
endpoint but I couldn't create the right query for this. Please help me with this.
Upvotes: 0
Views: 587
Reputation: 1200
You can use search api (https://dev.twitter.com/rest/public/search) with required query. For eg.
https://api.twitter.com/1.1/search/tweets.json?q=from%3Ascreen_name
where screen_name is the screen_name of the user whose tweets you want.
Upvotes: 1
Reputation: 1900
The GET search/tweets is the right endpoint to use to search for tweets using a specific hashtag. Twitter launched Fabric a month ago, a SDK that implement API calls natively.
You can check how to do API calls here: https://dev.twitter.com/twitter-kit/ios/api
An example:
// Objective-C
NSString *statusesShowEndpoint = @"https://api.twitter.com/1.1/statuses/show.json";
NSDictionary *params = @{@"id" : @"20"};
NSError *clientError;
NSURLRequest *request = [[[Twitter sharedInstance] APIClient]
URLRequestWithMethod:@"GET"
URL:statusesShowEndpoint
parameters:params
error:&clientError];
if (request) {
[[[Twitter sharedInstance] APIClient]
sendTwitterRequest:request
completion:^(NSURLResponse *response,
NSData *data,
NSError *connectionError) {
if (data) {
// handle the response data e.g.
NSError *jsonError;
NSDictionary *json = [NSJSONSerialization
JSONObjectWithData:data
options:0
error:&jsonError];
}
else {
NSLog(@"Error: %@", connectionError);
}
}];
}
else {
NSLog(@"Error: %@", clientError);
}
Upvotes: 1