测试Facebook应用的发布权限

时间:2016-04-04 13:57:59

标签: android facebook facebook-graph-api

我想测试我的facebook应用程序的发布权限,但是当使用图形api(s)来表示喜欢或评论时,我从facebook服务器收到错误。

用于发布喜欢的代码如下:

Bundle params = new Bundle();
        params.putString("url", "http://www.imdb.com/title/tt2015381/");
        new GraphRequest(
                AccessToken.getCurrentAccessToken(),
                "/" + facebookObjectId + "/likes",
                params,
                HttpMethod.POST,
                new GraphRequest.Callback() {
                    public void onCompleted(GraphResponse response) {
                        Log.i(TAG, "FACEBOOK GRAPH RESPONSE FOR POSTING LIKE: " + response);
                    }
                }
        ).executeAsync();

正在生成的相应错误是:

FACEBOOK GRAPH RESPONSE FOR POSTING LIKE: {Response:  responseCode: 403, graphObject: null, error: {HttpStatus: 403, errorCode: 200, errorType: OAuthException, errorMessage: (#200) App does not have permission to make this call}}

基本上暗示 应用程序无权进行此次调用

1 个答案:

答案 0 :(得分:0)

发布自定义内容:

    Bundle params = new Bundle();
    params.putString("object", linkURL);
    new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "/" + Profile.getCurrentProfile().getId() + "/og.likes",
            params,
            HttpMethod.POST,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {

                    Log.i(TAG, "FACEBOOK GRAPH RESPONSE FOR POSTING LIKE: " + response);
                }
            }
    ).executeAsync();

删除自定义内容:

    Bundle params = new Bundle();
    params.putString("object", linkURL);
    new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "/" + likeActionInstanceId,
            params,
            HttpMethod.DELETE,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
                    Log.i(TAG, "FACEBOOK GRAPH RESPONSE FOR DELETING LIKE: " + response);
                }
            }
    ).executeAsync();

此处likeActionInstanceId是成功提交之后收到的id

注意:目前无法从您自己的应用中添加评论。评论镜像在Facebook处于测试阶段。