tags:

views:

55

answers:

2

Hi everyone

I am using at my iphone app this code but i can not see the post on my twitter. I am not getting an error back.

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:@"http://username:[email protected]/statuses/update.xml"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.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(@"Your Poem posted to Twitter successfully.");
else 
    NSLog(@"Could not post to Twitter");

Can anyone tell me what is wrong?

+1  A: 

Twitter disabled basic auth recently, you must use OAuth instead.

Paul Betts
+3  A: 

Basic authentication was removed in August. You must now use OAuth. See http://apiwiki.twitter.com/ for details.

Edit: There are several libraries to do this. I have been using this iPhone ready implementation of oauthconsumer: http://github.com/jdg/oauthconsumer

Peter DeWeese