无法从我的iPhone应用程序
问题描述:
我使用这个代码小块在Twitter上张贴张贴到Twitter,与真正的凭据到位“mytwitterloginname”和“mytwitterpassword”占位符:无法从我的iPhone应用程序
void _StartTwitter()
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString:@"http://mytwitterloginname:[email protected]/statuses/update.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
// The text to post
NSString *msg = @"testing";
// Set the HTTP request method
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[[NSString stringWithFormat:@"status=%@", msg]
dataUsingEncoding:NSASCIIStringEncoding]];
NSURLResponse *response;
NSError *error;
if ([NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error] != nil)
NSLog(@"Posted to Twitter successfully.");
else
NSLog(@"Error posting to Twitter.");
}
但即使我的控制台说这个帖子是成功的,它仍然没有发生。
任何人都可以帮助我找到问题所在?,谢谢。
答
虽然twitter现在只有O-AUTH身份验证,所以你不能简单地通过他们的REST服务发布信息了。
您可能需要重新整合其新的OAUTH服务。
UPDATE:
这里是链接到OAUTH例子: Twitter - OAUTH
,我需要做的令人失望的部分是为了去通过愚蠢的步骤叽叽喳喳现在创建一个Web用户界面视图强制执行。在进行身份验证请求(绑定到在Twitter中创建的应用程序)之后,我的会话被创建并从那里开始发布消息。
不像以前的REST服务那么友好:/
+0
不知道。要搜索一些关于OAUTH认证或实际的Twitter教程的信息。谢谢。 – 2011-02-24 20:07:22
您需要检查返回的响应对象。仅仅因为连接成功并不意味着所请求的操作是成功的。 – Nick 2011-02-24 20:06:48