ios swift 2 post facebook page 代表专页

ios swift 2 post on facebook page on behalf of the page

facebook 在页面上为 post 提供了以下代码,但是我无法找到代码的 swift 版本,同时考虑到 facebook 已移至 FBSDKGraphRequest v2.6

NSDictionary *params = @{
  @"message": @"This is a test message",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{page-id}/feed"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

这就完成了工作

let request = FBSDKGraphRequest(graphPath: "page-id/feed", parameters: ["Message" : "Hello there"], HTTPMethod: "POST")

    request.startWithCompletionHandler { (connection, result, error) in
        //Handle the request
    }

您可以根据需要设置参数。在这里阅读参数:FBSDK

在此处阅读更多内容:Facebook