【问题标题】:Changes coming in Version 1.1 of the Twitter API in iPhoneiPhone 中 Twitter API 1.1 版中的变化
【发布时间】:2013-06-20 13:48:05
【问题描述】:
【问题讨论】:
标签:
iphone
twitter
version
【解决方案1】:
访问https://dev.twitter.com/docs/ios/making-api-requests-slrequest
https://dev.twitter.com/docs/oauth/xauth
您可以使用以下方法获得身份验证:
NSString *base64 = @"基本 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"];
作为回应,您将像这样获得您的应用程序的 authtoken
{"token_type":"bearer","access_token":"AAAAAAAAAAAAAAAAAAAAAMddRQAAAAAAXRP6Axur1RS%2Fv9YFtJ7TijyPAGo%3DpmNowwOGf3dZTHDiH2gnCcv7qNIyGZcyV2IW5YFTBs"}