I want to get a list of tweets using the Twitter Search API. But recently, twitter has launched a new version of version 1.1 and requires authorization. I use the STTwitter library to interact with the Twitter API.
I am using the STTwitter_ios project, which you can find here: https://github.com/nst/STTwitter/tree/master/ios
Now I have written one example function: fetchTweets. Authorization works successfully, and I get a list if I search for a word (without spaces or special characters). But when I try to find a keyword with spaces or special characters such as "New York", "New or York", etc., then it returns an error:
In the method, - (void) connectionDidFinishLoading: (NSURLConnection *) connection
I get an error: {"errors": [{"message": "Failed to authenticate you", "code": 32}]}
- (void) fetchTweets { STTwitterAPIWrapper *twitter = [STTwitterAPIWrapper twitterAPIWithOAuthConsumerName:OAUTH_CONSUMER_NAME consumerKey:OAUTH_CONSUMER_KEY consumerSecret:OAUTH_CONSUMER_SECRET oauthToken:OAUTH_TOKEN oauthTokenSecret:OAUTH_SECRET_TOKEN]; NSString *query = @"New york"; NSString *searchQuery = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [twitter getSearchTweetsWithQuery:searchQuery successBlock:^(NSDictionary *searchMetadata, NSArray *statuses) { NSLog(@"Search data : %@",searchMetadata); NSLog(@"\n\n Status : %@",statuses); } errorBlock:^(NSError *error) { NSLog(@"Error : %@",error); }]; }
Any help or suggestions would be appreciated!
Thanks!
source share