I have used the twitter api provided by twitter,to get the details but
not able to execute it, even tried to pass the authentication data
like consumer secret key, consumer key, token but the result is same.
I am able to login and receiving twitter authentication token but not able to get user details.
Below code is used by me (I am using MGtwitter engine) :
NSMutableURLRequest *request =[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/1.1/users/show.json?screen_name=%@",username]]];
NSData *returnData = [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ];
NSString *returnString = [[NSString alloc]initWithData:returnData encoding:NSUTF8StringEncoding];
NSError *err = nil;
twitterLogin = [NSJSONSerialization JSONObjectWithData:[returnString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&err];
Error is shown as below:
errors = (
{
code = 215;
message = "Bad Authentication data";
} );
First, you need to
Authenticateyour request (Get permission).second, see follow these steps:
1.Download FHSTwitterEngine Twitter Library.
2.Add the folder
FHSTwitterEngine" to your project and#import "FHSTwitterEngine.h".3.add
SystemConfiguration.frameworkto your project.and don't forget to import the delegate
FHSTwitterEngineAccessTokenDelegate.when the Login window is presented, enter your Twitter
UsernameandPasswordtoauthenticateyour request.That's all. I just got the screen_name from a search Query, you can get a timeline for a user using the following methods:
instead of the search method above.
Note: see the
FHSTwitterEngine.hto know what method you need to use. Note: to get the<consumer_key>and the<consumer_secret>you need to to visit this link to register your app in Twitter.