2010-09-19 126 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。