【问题标题】:ios swift 2 post on facebook page on behalf of the pageios swift 2 代表页面在facebook页面发帖
【发布时间】:2016-04-17 17:10:00
【问题描述】:

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
}];

【问题讨论】:

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


    【解决方案1】:

    这样就完成了

    let request = FBSDKGraphRequest(graphPath: "page-id/feed", parameters: ["Message" : "Hello there"], HTTPMethod: "POST")
    
        request.startWithCompletionHandler { (connection, result, error) in
            //Handle the request
        }
    

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

    在此处阅读更多信息:Facebook

    【讨论】:

    • 感谢@Joakim,我尝试了上面的代码,但消息没有发布到 facebook 页面,我还阅读了文档我是否遗漏了什么
    • 对不起..错误的代码。这将获得一个页面提要。虽然参数错误。我将进行编辑
    • 此代码现在将代表页面发布帖子。请记住拥有有效的访问令牌和正确的参数。之前的代码没有发出 POST 请求,所以它失败了。但现在它做到了
    • 我是否需要在参数中传递访问令牌,例如 ["Message" : "Hello there","access_token":"generated-access-token"]
    猜你喜欢
    • 2019-02-25
    • 1970-01-01
    • 2014-05-27
    • 1970-01-01
    • 2014-11-17
    • 2020-03-21
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    相关资源
    最近更新 更多