Question

In my app, i am trying to integrate posting messages to twitter. (I've generated consumer key and consumer secret in my twitter applicatin.
I'm using following code.

#pragma mark SA_OAuthTwitterEngineDelegate
- (void) storeCachedTwitterOAuthData: (NSString *) data forUsername: (NSString *) username {
    NSUserDefaults          *defaults = [NSUserDefaults standardUserDefaults];

    [defaults setObject: data forKey: @"authData"];
    [defaults synchronize];
}

- (NSString *) cachedTwitterOAuthDataForUsername: (NSString *) username {
    return [[NSUserDefaults standardUserDefaults] objectForKey: @"authData"];
}

- (void) twitterOAuthConnectionFailedWithData: (NSData *) data
{
    NSLog(@"Failed");
}
//=============================================================================================================================
#pragma mark SA_OAuthTwitterControllerDelegate
- (void) OAuthTwitterController: (SA_OAuthTwitterController *) controller authenticatedWithUsername: (NSString *) username {
    NSLog(@"Authenicated for %@", username);
}

- (void) OAuthTwitterControllerFailed: (SA_OAuthTwitterController *) controller {
    NSLog(@"Authentication Failed!");
}

- (void) OAuthTwitterControllerCanceled: (SA_OAuthTwitterController *) controller {
    NSLog(@"Authentication Canceled.");
}

Its authorizing successfully, but the following delegate method is printing null username.

- (void) OAuthTwitterController: (SA_OAuthTwitterController *) controller authenticatedWithUsername: (NSString *) username

The following is the response that I'm getting:

2011-12-29 00:01:57.965 OAuthTwitterDemo[4656:207] Failed
2011-12-29 00:01:57.966 OAuthTwitterDemo[4656:207] Authenicated for (null)

Can some one suggest me what's the mistake in my code?

Was it helpful?

Solution

try to replace the http with https in this function

- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate {
if (self = (id) [super initWithDelegate: delegate]) {
        self.requestTokenURL = [NSURL URLWithString: @"https://twitter.com/oauth/request_token"];
        self.accessTokenURL = [NSURL URLWithString: @"https://twitter.com/oauth/access_token"];
        self.authorizeURL = [NSURL URLWithString: @"https://twitter.com/oauth/authorize"];
    }
return self;
}

OTHER TIPS

The problem is not with the URL's for request, authorize etc. There's a change in the twitter or iOS itself which is causing issues. For iOS 4, without any changes in twitter engine, its work perfect. But on iOS5, we have to use twitter framework. This solved my problem.

Yep..!it works for me :) , the url with http will work without problem in ios ios 4.* but you have to replace to https to work with ios 5.1 version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top