android - 错误 #200 Facebook SDK Android

标签 android facebook sdk facebook-login post-update

亲爱的 friend 们, 我正在使用 Facebook SDK 在 Android 上开发一个与 Facebook 集成的应用程序。我的应用程序应该只能发布一个链接。我使用这段代码:

this.req = new Request(session, "me/feed", b, HttpMethod.POST,
                    callback);

            RequestAsyncTask sendRequest = new RequestAsyncTask(req);
            sendRequest.execute();

使用此权限:

public static final List<String> PERMISSIONS = Arrays
            .asList("publish_actions" );

实际上,在我的开发者帐户上发布链接效果很好。一旦我使用另一个帐户,我就会收到此错误消息:

(#200) The user hasn't authorized the application to perform this action

你能帮帮我吗?或者只是给个提示?

最佳答案

我认为您在 Facebook 帐户上添加的 KeyHash 允许您共享一些链接。为了能够在用户墙上发布一些东西,你必须尊重这个 facebook 的“最佳实践”:这是我的生产代码,工作正常:

private void publishStory(String hash, String title, String user) {

    Session session = Session.getActiveSession();

    if (session != null){
        // Check for publish permissions    
        List<String> permissions = session.getPermissions();
        if (!isSubsetOf(PERMISSIONS, permissions)) {
            pendingPublishReauthorization = true;
            Session.NewPermissionsRequest newPermissionsRequest = new Session
                    .NewPermissionsRequest(getActivity(), PERMISSIONS);
            session.requestNewPublishPermissions(newPermissionsRequest);
            return;
        }
        Bundle postParams = new Bundle();
        postParams.putString("name", title);
        postParams.putString("caption", "By Recommend Android");
        postParams.putString("description", user+" "+"STRONGLY recommends"+" "+title);
        postParams.putString("link", "http://re.co/"+hash);
        postParams.putString("picture", "http://re.co/assets/img/useful-exp.png");

        Request.Callback callback= new Request.Callback() {
            public void onCompleted(Response response) {
                JSONObject graphResponse = response
                        .getGraphObject()
                        .getInnerJSONObject();
                String postId = null;
                try {
                    postId = graphResponse.getString("id");
                } catch (JSONException e) {
                    Log.i(TAG,
                            "JSON error "+ e.getMessage());
                }
                FacebookRequestError error = response.getError();
                if (error != null) {
                    debug.print("erreur");
                } else {
                    debug.print("erreur2");
                }
            }
        };
        Request request = new Request(session, "me/feed", postParams, 
                HttpMethod.POST, callback);

        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
    }
}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
    for (String string : subset) {
        if (!superset.contains(string)) {
            return false;
        }
    }
    return true;
}

关于android - 错误 #200 Facebook SDK Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17543999/

相关文章:

android - flutter - 如何检测设备的声音偏好,是静音还是振动模式?

ios - 不调用 Facebook loginButton didCompleteWithResult

c# - Facebook v3 sdk monodroid 绑定(bind)

java - Microsoft Project Online SDK API/REST API 支持

android - Eclipse安装软件报错

Android 应用程序首次启动需要更多时间甚至 30 秒或更长时间

android - 您所在的国家/地区不支持 Google Play 购买 - 演示测试卡

java - 三星远程测试实验室 (RTL) : how to bind the device to Eclipse/debugger

facebook - Facebook 'profile stream' 又名墙帖的 API 是什么?

android - 创建使用 AAR 文件作为依赖项的 Android 库