2012-12-12 107 views
1

在我的iPhone应用程序我访问我的Facebook信息并将其发送到服务器。从服务器的Facebook共享应该发生 我已经在FB中创建了我的应用程序,同时点击同步按钮,我可以去FB登录页面。它在嵌入后请求身份验证facebook分享从iPhone应用程序

但它只是要求“基本信息“不为公众共享等(我已经包含在我的FB应用程序)

-(IBAction)fbConnect:(id)sender{ 

    flag = 1; 
    AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate]; 

    if (appDelegate.session.isOpen) { 

    [self updateView]; 
    } else { 
    if (appDelegate.session.state != FBSessionStateCreated) { 
     appDelegate.session = [[FBSession alloc] init]; 
    } 

    [appDelegate.session openWithCompletionHandler:^(FBSession *session, 
                FBSessionState status, 
                NSError *error) { 
     [self updateView]; 
    }]; 
    } 


    NSLog(@"string issss %@",string); 


    } 

    - (void)updateView { 
     AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate]; 
     if (appDelegate.session.isOpen) { 

     string = [NSString stringWithFormat:@"%@", 
       appDelegate.session.accessToken]; 

     NSLog(@"string issss %@",string); 
     NSString *urlstrng; 
     if(flag == 1){ 
     urlstrng = [NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@",string]; 
      [self dataFetching:urlstrng]; 
    } 
    if(flag == 2){ 
     urlstrng = [NSString stringWithFormat:@"https://graph.facebook.com/me/friends? access_token=%@",string]; 
     [self dataFetching:urlstrng]; 
    } 


    } else { 

    string = [NSString stringWithFormat:@"%@", 
       appDelegate.session.accessToken]; 
    NSString *urlstrng; 
    if(flag == 1){ 
     urlstrng = [NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@",string]; 
     [self dataFetching:urlstrng]; 
     } 

    if(flag == 2){ 
     urlstrng = [NSString stringWithFormat:@"https://graph.facebook.com/me/friends?access_token=%@",string]; 
     [self dataFetching:urlstrng]; 
    } 


     } 
    } 

     -(void)dataFetching:(NSString*)strng1{ 

     NSURL *url = [NSURL URLWithString:strng1]; 
     ProfileConnector *obj = [[ProfileConnector alloc] init]; 
     obj.delegate1 = self; 
     [obj parsingJson:url]; 

     } 

enter image description here

回答

0

我相信你是不是通过您的代码请求额外的项目。你可以通过使用openSessionWithAllowLoginUI来完成。

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI { 

NSArray *permissions = [[NSArray alloc] initWithObjects: 
         @"user_location", 
         @"user_birthday", 
         @"user_likes", 
         @"email", 
         nil]; 
return [FBSession openActiveSessionWithPermissions:permissions 
             allowLoginUI:allowLoginUI 
           completionHandler:^(FBSession *session, 
                FBSessionState state, 
                NSError *error) { 
            [self sessionStateChanged:session 
                 state:state 
                 error:error]; 
           }]; 

}

+0

我在哪里可以使用这个...? –

+0

我在这里得到一个错误 - [self sessionStateChanged:session state:state error:error]; –

+0

在你的appdelegate。我相信你正在使用FacebookSDK。对? – Harikrishnan

相关问题