2013-01-24 27 views
5

Tôi vừa mới bắt đầu một ứng dụng mới với SDK iOS 3.1, tôi nhận thấy rằng quyền đọc và ghi được tách riêng.Cách đơn giản để xuất bản lên tường với ios SDK 3.1

Tôi đang tìm kiếm một cách đơn giản để công bố cho người sử dụng tường nhưng tôi ma chút nhầm lẫn với cơ chế ủy quyền

Nếu tôi có thể cho quyền ghi trong CompletionHandler của openActiveSessionWithReadPermissions, tôi nhận được lỗi sau

*** 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.' 

hoàn thànhHandler âm thanh như hành động được hoàn thành, vì vậy tôi không hiểu vấn đề với mã này là gì.

Mọi đề xuất?

-(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

Bạn đã kiểm tra tình trạng của phiên giao dịch là gì? bạn có thể đăng nhập giá trị của trạng thái không? –

Trả lời

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"]; 
} 
     }]; 
      } 
      }]; 
Các vấn đề liên quan