Facebook iOS sdk feed对话共享问题

时间:2013-05-29 13:50:35

标签: facebook

我正在使用最新的facebook sdk通过使用Feed对话共享功能在Facebook上分享短信。在Facebook上分享文本消息工作正常,但我面临的问题就像点击共享后再次出现登录对话框,即使我有有效的会话和登录用户。

enter image description here

- (BOOL)openSessionAllowingLoginUI:(BOOL)allowLoginUI
{
NSArray *permissions = [[NSArray alloc] initWithObjects:@"offline_access",@"publish_actions",@"read_stream", nil];

return [FBSession openActiveSessionWithPublishPermissions:permissions
                                          defaultAudience:FBSessionDefaultAudienceOnlyMe 
                                             allowLoginUI:YES
                                        completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {

                                            DLog(@"Facebook Error : %@", error);
                                            if (!error) {
                                                [self publishPost:self.shareMessage andLink:self.shareLink];
                                            }
                                        }];
}


- (void)publishPost:(NSString *)message andLink:(NSString *)url
{
// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"sample", @"name",
                               self.shareMessage, @"description",
                               self.shareLink, @"link",
                               nil];

[FBWebDialogs presentFeedDialogModallyWithSession:nil
                                       parameters:params
                                          handler:
 ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
     if (error) {
         // Error launching the dialog or publishing a story.
         NSLog(@"Error publishing post.");
     } else {
         if (result == FBWebDialogResultDialogNotCompleted) {
             // User clicked the "x" icon
             NSLog(@"User canceled post publishing.");
         } else {
             // Handle the publish feed callback
             NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
             if (![urlParams valueForKey:@"post_id"]) {
                 // User clicked the Cancel button
                 NSLog(@"User canceled story publishing.");
             } else {

                 // User clicked the Share button
                 [self displaySuccessMessage];
             }
         }
     }
 }];
 }

1 个答案:

答案 0 :(得分:0)

尝试致电

openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:

接着是

requestNewPublishPermissions:defaultAudience:completionHandler:

而不是打电话

openActiveSessionWithPublishPermissions:defaultAudience:allowLoginUI:completionHandler: