2013-01-24 39 views
5

我剛剛開始使用SDK iOS 3.1開發新應用程序,我注意到現在讀寫權限是分開的。使用ios SDK 3.1發佈到牆上的簡單方法

我正在尋找一種簡單的方法來發布到用戶牆上,但我是個與授權機制

有點困惑。如果我能在openActiveSessionWithReadPermissions的CompletionHandler寫權限,我收到以下錯誤

*** Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: It is not valid to reauthorize while a previous reauthorize call has not yet completed.' 

completionHandler聽起來像行動已完成,所以我不明白這個代碼有什麼問題。

有什麼建議嗎?

-(void)askWritePerms 
{ 
NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil]; 

[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions 
          defaultAudience:FBSessionDefaultAudienceFriends 
         completionHandler:^(FBSession *session, NSError *error) { 


    }]; 

} 


- (IBAction)publishFB:(id)sender 
{ 


     NSArray *permissions = [NSArray arrayWithObjects:@"email", nil]; 

     [FBSession openActiveSessionWithReadPermissions:permissions 
            allowLoginUI:YES 
           completionHandler:^(FBSession *session, FBSessionState status, NSError *error) { 
          [self askWritePerms]; 

        } 
+0

你檢查什麼是會話的狀態?你能記錄狀態的值嗎? –

回答

0
For publishing in wall in facebook use the following code 
[[FBSession activeSession] reauthorizeWithPublishPermissions:@[ @"publish_stream",@"publish_actions" ] defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *authSession, NSError *authError) { 

      // If auth was successful, create a status update FBRequest 
      if (!authError) { 
NSMutableDictionary* photosParams = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
                imageurl,@"source", 
                urlstring,@"link",@"Appname",@"name",@"Your app description",@"description", 
                nil]; 


       [FBRequestConnection startWithGraphPath:@"me/feed" parameters:photosParams HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
       if (error) 
       { 
        [self showAlert:@"Connection Error...Try Again"]; 
} 
     }]; 
      } 
      }]; 
相關問題