通过iPhone应用程序更新linkedin中的状态

时间:2012-07-30 10:57:45

标签: ios5 linkedin

到目前为止,这是我的代码:

-(IBAction)postToLinkedin{   
   rdEngine = [RDLinkedInEngine engineWithConsumerKey:LI_kOAuthConsumerKey consumerSecret:LI_kOAuthConsumerSecret delegate:self] ; 
   RDLinkedInAuthorizationController* controller = [RDLinkedInAuthorizationController authorizationControllerWithEngine:rdEngine delegate:self];
   if( controller) { 
        [self presentModalViewController:controller animated:YES];
        }
   else   
       {
       NSLog(@"alreadyy authenticated");       
       }
 }

-(void)linkedInEngineAccessToken:(RDLinkedInEngine *)engine setAccessToken:(OAToken *)token {
    NSLog(@"1111111");
    [token storeInUserDefaultsWithServiceProviderName:@"LinkedIn" prefix:@"Demo"];    
    }

- (void)linkedInEngineAccessToken:(RDLinkedInEngine *)engine removeAccessToken:(OAToken *)token {
    [token removeAccessTokenUsingServiceProviderName:@"LinkedIn" prefix:@"Demo"];
    }

- (OAToken *)linkedInEngineAccessToken:(RDLinkedInEngine *)engine {    
    return [[OAToken alloc] initWithUserDefaultsUsingServiceProviderName:@"LinkedIn" prefix:@"Demo"] ;
    NSLog(@"3333");
    }

- (void)linkedInEngine:(RDLinkedInEngine *)engine requestSucceeded:(RDLinkedInConnectionID *)identifier withResults:(id)results {
    NSLog(@"++ LinkedIn engine reports success for connection %@\n%@", identifier, results);
   UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"Successfully Tweeted" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show];
    }

- (void)linkedInEngine:(RDLinkedInEngine *)engine requestFailed:(RDLinkedInConnectionID *)identifier withError:(NSError *)error {
    NSLog(@"++ LinkedIn engine reports failure for connection %@\n%@", identifier, [error localizedDescription]);
    }

//#pragma mark -
//#pragma mark RDLinkedInAuthorizationControllerDelegate

- (void)linkedInAuthorizationControllerSucceeded:(RDLinkedInAuthorizationController *)controller {
    NSLog(@"Authentication succeeded.");
    NSLog(@"Fetching current user's profile on connection %@", [controller.engine profileForCurrentUser]); 
    [rdEngine updateStatus:@"hello"];
    }

- (void)linkedInAuthorizationControllerFailed:(RDLinkedInAuthorizationController *)controller {
    NSLog(@"Authentication failed!");
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error occurred while updating Linkedin status." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show]; 
    }

- (void)linkedInAuthorizationControllerCanceled:(RDLinkedInAuthorizationController *)controller {
    NSLog(@"Authentication was cancelled.");
    }

代码无效,因为状态未获得更新。 你能告诉我哪里出错了吗?

1 个答案:

答案 0 :(得分:0)

为什么要在postToLinkedIn中显示授权控制器? 您可以在此处查看共享API https://developer.linkedin.com/documents/share-api