ios swift 2在Facebook页面上代表页面发布

时间:2016-04-17 17:10:00

标签: swift facebook facebook-graph-api swift2 xcode7

facebook提供了以下代码发布到页面,但是我也无法找到快速版本的代码,同时考虑到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
}];

1 个答案:

答案 0 :(得分:0)

这就完成了工作

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

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

您可以随心所欲地设置params。阅读这里的参数:FBSDK

在此处阅读更多内容:Facebook