AFNetworking的扩展,用于支持OAuth1.0a认证。
示例代码:
AFOAuth1Client*twitterClient=[[[AFOAuth1Clientalloc]initWithBaseURL:[NSURLURLWithString:@"https://twitter.com/oauth/"]key:@"..."secret:@"..."]autorelease];//Yourapplicationwillbesenttothebackgrounduntiltheuserauthenticates,andthentheappwillbebroughtbackusingthecallbackURL[twitterClientauthorizeUsingOAuthWithRequestTokenPath:@"/request_token"userAuthorizationPath:@"/authorize"callbackURL:[NSURLURLWithString:@"x-com-YOUR-APP-SCHEME://success"]accessTokenPath:@"/access_token"success:^(AFOAuth1Token*accessToken){NSLog(@"Success:%@",accessToken);NSLog(@"YourOAuthcredentialsarenowsetinthe`Authorization`HTTPheader");}failure:^(NSError*error){NSLog(@"Error:%@",error);}];
评论