【问题标题】:session.state FBSessionStateCreated is not posting on fb wall in iossession.state FBSessionStateCreated 未在 ios 的 fb 墙上发布
【发布时间】:2014-12-30 07:05:00
【问题描述】:

我遇到了一个问题。当我在我的应用程序中登录 Facebook 帐户时。在第一次发布时,我得到了这个 FBSession 响应,它工作正常并正常发布在 FBWall 上。

FBSESSION <FBSession: 0x1c31bbc0, state: FBSessionStateCreatedTokenLoaded, loginHandler: 0x0, appID: 524460600950223, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x176c99b0>, expirationDate: 2015-02-27 10:42:15 +0000, refreshDate: 2014-12-30 06:24:28 +0000, attemptedRefreshDate: 0000-12-30 00:00:00 +0000, permissions:(
"create_note",
"basic_info",
"share_item",
"read_stream",
"status_update",
"publish_actions",
"user_friends",
"publish_checkins",
"video_upload",
"export_stream",
"publish_stream",
"photo_upload",
installed,
email,
"public_profile",
"user_birthday",
"user_status"
)>

从第 2 次开始,我正在尝试发布我得到如下所示的 FBSession,它不会在 FBWall 上发布

FBSESSION <FBSession: 0x1d05fac0, state: FBSessionStateCreated, loginHandler: 0x0, appID: 524460600950223, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x176c99b0>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0000-12-30 00:00:00 +0000, permissions:(null)>

//This will happens at the time of Loginwithfacebook account... otherwise it will work fine  
//can any one help me. Thanks in advance

【问题讨论】:

    标签: ios objective-c facebook fbconnect posting


    【解决方案1】:

    我得到了解决方案。如果我们使用 facebook 帐户登录,则无需检查会话。只需发布您想要的内容

    FBSession *session = [[FBSession alloc] init];
    
    NSLog(@"FBSESSION %@", session);
    
    if (session.state == FBSessionStateCreatedTokenLoaded || session.state == FBSessionStateOpen )
    {
    
        [[[[iToast makeText:@"Post on wall success"] setGravity:iToastGravityBottom] setDuration:iToastDurationShort]show];
        // even though we had a cached token, we need to login to make the session usable
        [session openWithCompletionHandler:^(FBSession *session,
                                             FBSessionState status,
                                             NSError *error) {
            [FBSession setActiveSession:session];
            [FBRequestConnection startWithGraphPath:@"/me/feed"
                                         parameters:params
                                         HTTPMethod:@"POST"
                                  completionHandler:^(FBRequestConnection *connection, id result, NSError *error){
                                      NSLog(@"error-- %@",error);
                                  }];
        }];
    }
    

    以前我的代码是上面显示的这样的

    我刚刚在上面的代码中添加了 else 部分,它将正常工作。我的问题将得到解决。

    else
    {
    
    [[[[iToast makeText:@"Post on wall success"] setGravity:iToastGravityBottom] setDuration:iToastDurationShort]show];
    [FBRequestConnection startWithGraphPath:@"/me/feed"
                                 parameters:params
                                 HTTPMethod:@"POST"
                          completionHandler:^(FBRequestConnection *connection, id result, NSError *error){
                              NSLog(@"error-- %@",error);
                          }];
    }
    

    【讨论】:

      【解决方案2】:

      需要修改代码中的以下行:

      if (session.state == FBSessionStateCreatedTokenLoaded || session.state == FBSessionStateOpen )
      

      if (session.state == FBSessionStateCreatedTokenLoaded || session.state == FBSessionStateCreated )
      

      如果您的会话状态已经打开,则无需再次打开 FBSession。

      如果会话已创建或令牌已加载,则您需要再次打开会话。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-12
        • 2012-11-18
        • 1970-01-01
        • 2011-02-16
        • 1970-01-01
        相关资源
        最近更新 更多