0
votes

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?

2

2 Answers

3
votes

Basic authentication was removed in August. You must now use OAuth. See https://dev.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

1
votes

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