xcode - 为 iOS 客户端寻找 OAuth 版本的 Twitter 代码

标签 xcode ios twitter twitter-oauth

我正在从《Head First iPhone Programming》一书中学习 iOS 编程。在一项练习中,他们有使用基本授权的 Twitter 示例代码。既然 Twitter 使用了 OAuth,我如何才能获得 OAuth 代码以便测试我的客户端?我需要在 Twitter 上注册我的应用程序吗?我该怎么做,因为它只是一个测试应用程序?

这是代码的基本授权版本;我正在寻找 OAuth 版本:

//TWITTER BLACK MAGIC
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://YOUR_TWITTER_USERNAME:YOUR_TWITTER_PASSWORD@twitter.com/statuses/update.xml"]
                                                        cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                    timeoutInterval:60.0];

[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[[NSString stringWithFormat:@"status=%@", themessage] dataUsingEncoding:NSASCIIStringEncoding]];
NSURLResponse* response;
NSError* error;
NSData* result = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
NSLog(@"%@", [[[NSString alloc] initWithData:result encoding:NSASCIIStringEncoding] autorelease]);

//END TWITTER BLACK MAGIC 

最佳答案

要获得 Twitter oAuth 访问权限,您需要在 http://dev.twitter.com 上创建应用程序并检索 Consumer Key 和 Consumer Auth。

也许本教程可以帮助您:

http://mobile.tutsplus.com/tutorials/iphone/twitter-api-iphone/

关于xcode - 为 iOS 客户端寻找 OAuth 版本的 Twitter 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5554430/

相关文章:

ios - 使用 iOS 社交框架为任何用户授权 session ?

ios - 无法使用免费的苹果开发者帐户下载配置文件

ios - 实现前置视频 iAd

ios - 接收返回的后台线程最终会自行关闭吗?

objective-c - 以编程方式检测是否正在卸载应用程序ios

python - 在python中读取JSON文件: ValueError

推特 API : timestamp out of Bounds when calling oauth request_token

ios - Collection View 布局为零,我已经尝试了一切

ios - UIButton 没有被实例化

ios - iOS 中 UIDatePicker 的默认日期