2012-10-26 39 views
2

我正在使用Parse移動平臺在Facebook時間線上發佈Feed。這是他們在他們的文檔中所說的:Note that if you already have the Facebook SDK installed in your app, our version of the Facebook SDK will happily work alongside it.發佈到Facebook的鏈接使用Parse的時間線

看一看hereThe Parse SDK includes the entire Facebook SDK. All the classes are namespaced with PF_ to avoid conflicts with existing libraries. So, for example, the main Facebook object class in our SDK is PF_Facebook.

這一個完美的作品使用Facebook SDK

- (IBAction)postFacebook:(UIButton *)sender {  
    self.postParams = 
    [[NSMutableDictionary alloc] initWithObjectsAndKeys: 
    @"https://developers.facebook.com/ios", @"link", 
    @"https://developers.facebook.com/attachment/iossdk_logo.png", @"picture", 
    @"Facebook SDK for iOS", @"name", 
    @"Here we go", @"message", 
    @"Build great social apps and get more installs.", @"caption", 
    @"The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.", @"description", 
    nil]; 

    [FBRequestConnection startWithGraphPath:@"me/feed" parameters:self.postParams HTTPMethod:@"POST" 
    completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
     [self showAlert:@"Link is posted" result:result error:error]; 
    }]; 
} 

但是當我使用PF_FBRequestConnection,這是行不通的:

[PF_FBRequestConnection startWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST" 
     completionHandler:^(PF_FBRequestConnection *connection, id result, NSError *error) { 
      [self showAlert:@"Link is posted" result:result error:error]; 
    }]; 

在控制檯中的錯誤:

Error: HTTP status code: 403 

事情是我可以發佈photo or Status使用解析,但不是你看到的鏈接。

我很感激任何幫助。

回答

2

問題是我使用的Parse框架的版本。你也可以查看here

例如,這一次沒有支持該版本(1.1.12):

[PF_FBSession.activeSession handleDidBecomeActive]; 

在新版本(1.1.13)問題就解決了。所以,我可以有這樣的方法:

// Convenience method to perform some action that requires the "publish_actions" permissions. 
- (void) performPublishAction:(void (^)(void)) action { 
    // we defer request for permission to post to the moment of post, then we check for the permission 
    if ([PF_FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) { 
     // if we don't already have the permission, then we request it now 
     [PF_FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"] 
      defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(PF_FBSession *session, NSError *error) { 
       if (!error) { 
        action(); 
       } 
      //For this example, ignore errors (such as if user cancels). 
     }]; 
    } else { 
     action(); 
    } 
} 

並以這種方式使用它:

[self performPublishAction:^{ 
     [PF_FBRequestConnection startWithGraphPath:@"me/feed" parameters:self.postParams HTTPMethod:@"POST" 
      completionHandler:^(PF_FBRequestConnection *connection, id result, NSError *error) { 
       [self showAlert:@"Link is posted" result:result error:error]; 
     }]; 
    }]; 
+0

謝謝您的回答,它真的幫了我! – edzio27

+0

我得到一個錯誤 「[0] \t(空)\t @」 com.facebook.sdk:ErrorInnerErrorKey 「:(無摘要)\t」 –

+0

而這個 「[1] \t(空)\t @」 com.facebook.sdk :ErrorSessionKey「:(無摘要)\t和」[2] \t(null)\t @「com.facebook.sdk:HTTPStatusCode」:(long)200「 –

0

你必須檢查你的應用程序的權限。來自Facebook SDK documentation

insufficient_scope:該請求需要比訪問令牌提供的更高的權限。資源服務器應該使用HTTP 403(禁止)狀態碼進行響應,並且可以將「範圍」屬性包含在訪問受保護資源所需的範圍內。

相關問題