jeudi 1 mai 2014

Changements à venir dans la Version 1.1 de l'API de Twitter dans iPhone - Stack Overflow


I am using twitter API version V1.0 for my new iphone application .I am successfully able to do this using twitters v1.0 of the API and all works perfectly. Simply making a request to http://api.twitter.com/1/statuses/user_timeline.json?screen_name=userid retrieves all the information that I require. since v1.0 has been deprecated and V1.1 requires authentication for each request, I get a bad authorization error (HTTP response status: 400)using this API. What are the Changes i need to do in my appication .how to generate OAuth request headers,Do i need register my application ?How can i get authentication for new version?


I hope the above makes sense and any help would be appreciated.


Thanks in advance.




Visit https://dev.twitter.com/docs/ios/making-api-requests-slrequest


https://dev.twitter.com/docs/oauth/xauth


u can get the authentication using following method:


NSString *base64 = @"Basic NFRLWGlZY3l1aHJ4OVJaUWI5RW5BOmdVMXlvcVV6YzBNZUhUQmFXdVRZU2NtZHlIWDFOZXhwZmxqRE16bm01aw=="; //oauth_consumer_secret,oauth_consumer_key NSURL *urlAPI = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/oauth2/token"]];


ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:urlAPI];
[request setDelegate:self];
[request setRequestMethod:@"POST"];

[request addRequestHeader:@"Authorization" value:base64];

[request addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded;charset=UTF-8"];

[request setPostValue:@"client_credentials" forKey:@"grant_type"];

In response u will get the authtoken for your application like this


{"token_type":"bearer","access_token":"AAAAAAAAAAAAAAAAAAAAAMddRQAAAAAAXRP6Axur1RS%2Fv9YFtJ7TijyPAGo%3DpmNowwOGf3dZTHDiH2gnCcv7qNIyGZcyV2IW5YFTBs"}



I am using twitter API version V1.0 for my new iphone application .I am successfully able to do this using twitters v1.0 of the API and all works perfectly. Simply making a request to http://api.twitter.com/1/statuses/user_timeline.json?screen_name=userid retrieves all the information that I require. since v1.0 has been deprecated and V1.1 requires authentication for each request, I get a bad authorization error (HTTP response status: 400)using this API. What are the Changes i need to do in my appication .how to generate OAuth request headers,Do i need register my application ?How can i get authentication for new version?


I hope the above makes sense and any help would be appreciated.


Thanks in advance.



Visit https://dev.twitter.com/docs/ios/making-api-requests-slrequest


https://dev.twitter.com/docs/oauth/xauth


u can get the authentication using following method:


NSString *base64 = @"Basic NFRLWGlZY3l1aHJ4OVJaUWI5RW5BOmdVMXlvcVV6YzBNZUhUQmFXdVRZU2NtZHlIWDFOZXhwZmxqRE16bm01aw=="; //oauth_consumer_secret,oauth_consumer_key NSURL *urlAPI = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/oauth2/token"]];


ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:urlAPI];
[request setDelegate:self];
[request setRequestMethod:@"POST"];

[request addRequestHeader:@"Authorization" value:base64];

[request addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded;charset=UTF-8"];

[request setPostValue:@"client_credentials" forKey:@"grant_type"];

In response u will get the authtoken for your application like this


{"token_type":"bearer","access_token":"AAAAAAAAAAAAAAAAAAAAAMddRQAAAAAAXRP6Axur1RS%2Fv9YFtJ7TijyPAGo%3DpmNowwOGf3dZTHDiH2gnCcv7qNIyGZcyV2IW5YFTBs"}


0 commentaires:

Enregistrer un commentaire