开发者

Run function on Login Success MGTwitterEngine ala FBConnect

I'm working with t开发者_Python百科he engine for the first time and am fairly new to iOS development. I' m curious though if there's a way to call a function after I log in successfully? I can't seem to get it to work along the lines that FBConnect called for fbDidLogin after your initial login function. I have MGTwitterEngineDelegate declared and I tried to use the following code after login:

//TWITTER LOGIN FUNCTION/////////////////////
-(void)twitLogin{
    NSLog(@"Inside of twitLogin...");
    if(![_engine isAuthorized]){  
        UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];  

        if (controller){  
            [self presentModalViewController: controller animated: YES]; 
            NSLog(@"Inside of Twitter login UIWebView.");
        }  else {
            NSLog(@"ONCE WE'RE LOGGED IN, LETS SEND THE TWEET!");
            NSString *tweet = [[NSString alloc] initWithFormat:@"My Tweet!"];
            [_engine sendUpdate:tweet];
            NSLog(@"You just tweeted: %@",tweet);
        }

    }  else {
        NSString *twitterToken=[[NSUserDefaults standardUserDefaults] objectForKey:@"authData"];
        NSLog(@"Twitter is authorized?: %@",twitterToken);
        //Twitter Integration Code Goes Here
        NSString *tweet = [[NSString alloc] initWithFormat:@"My Tweet!"];
        [_engine sendUpdate:tweet];
        NSLog(@"You just tweeted: %@",tweet);
    }

}

Any help is appreciated. Thanks so much!


The solution I posted previously didn't work %100, turned out I didn't have the right delegate set for login success in my controller:

#pragma mark SA_OAuthTwitterController Delegate

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

    NSLog(@"Authenticated with user %@", username);

    tweets = [[NSMutableArray alloc] init];
    [self updateStream:nil];
}

Hope that helps anyone!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜