2010-09-19 86 views
0

我在我的iPhone应用程序中使用此代码,但我无法在我的Twitter上看到帖子。我没有收到错误。twitter code iphone not working

NSMutableURLRequest *请求= [NSMutableURLRequest requestWithURL: [NSURL URLWithString:@ “http://username:[email protected]/statuses/update.xml”] 的CachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0]; //要发布的文字 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(@"Your Poem posted to Twitter successfully."); 
else 
    NSLog(@"Could not post to Twitter"); 

有谁能告诉我什么是错?

回答

1

Twitter最近禁用了基本身份验证,您必须改用OAuth。