发布在Facebook上与SDK 3.0和android不起作用(publishing on fac

2019-10-29 03:51发布

我设置连接在我的应用程序到fb:点击一个按钮的应用程序不会登录,上墙的帖子,然后就退出。 一切工作非常适合我和我的开发者账户,但与其他手机和其他帐户尝试,如果安装官方FB的应用程序,该应用程序并没有发布任何。 我刚刚更改密钥哈希,我没有使用debug.keystore而是一个新的密钥库.....任何人都可以帮我???? 非常感谢你!

我也跟着从FB教程,这是我的登录方法

private void onClickLogin() {
    Session session = Session.getActiveSession();
    login=true;
    if (session!=null && !session.isOpened() && !session.isClosed()) {
        session.openForPublish(new Session.OpenRequest(this)
            .setPermissions(Arrays.asList("publish_actions"))
            .setCallback(callback));
    } else {
        Session.openActiveSession(getActivity(), this, true, callback);
    }
}   

这是所有的“有趣”的代码

    boolean login= false;
private Session.StatusCallback callback = new Session.StatusCallback() {
    @Override
    public void call(Session session, SessionState state, Exception exception) {
        onSessionStateChange(session, state, exception);
    }
};
private UiLifecycleHelper uiHelper;
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;
@Override
public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(getActivity(), callback);
    uiHelper.onCreate(savedInstanceState);

}

public void setEnt(Entry e) {
    art=e;
}
@Override
public void onResume() {
    super.onResume();
     Session session = Session.getActiveSession();
    uiHelper.onResume();
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    uiHelper.onActivityResult(requestCode, resultCode, data);
}

@Override
public void onPause() {
    super.onPause();
    uiHelper.onPause();
}

@Override
public void onDestroy() {
    super.onDestroy();
    uiHelper.onDestroy();
}

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    uiHelper.onSaveInstanceState(outState);
}
private void onClickLogin() {
    Session session = Session.getActiveSession();
    login=true;
    if (session!=null && !session.isOpened() && !session.isClosed()) {
        session.openForPublish(new Session.OpenRequest(this)
            .setPermissions(Arrays.asList("publish_actions"))
            .setCallback(callback));
    } else {
        Session.openActiveSession(getActivity(), this, true, callback);
    }
}   

private void onSessionStateChange(Session session, SessionState state, Exception exception) {

     if (state.isOpened()) {
                publishStory();
        } else if (state.isClosed()) {
        }

}

private void publishStory() {
    Session session = Session.getActiveSession();
    if(login){
    if (session != null){


        Bundle postParams = new Bundle();
        postParams.putString("name", art.getTitle());
        postParams.putString("caption", art.getSection());
        postParams.putString("description", "xxx");
        postParams.putString("link", "xxx");
        postParams.putString("picture", "xxx");

        Request.Callback callback= new Request.Callback() {
            public void onCompleted(Response response) {
                JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
                String postId = null;
                try {
                    postId = graphResponse.getString("id")+"  articolo postato";

                } catch (JSONException e) {
                    Log.i(TAG,
                        "JSON error "+ e.getMessage());
                }
                FacebookRequestError error = response.getError();
                if (error != null) {
                    Toast.makeText(getActivity()
                         .getApplicationContext(),
                         error.getErrorMessage(),
                         Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(getActivity()
                             .getApplicationContext(), 
                             postId,
                             Toast.LENGTH_LONG).show();
                        logout();
                }
            }
        };

        Request request = new Request(session, "me/feed", postParams, 
                              HttpMethod.POST, callback);

        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
        Log.v("FB", "FINE");
    }
    }
}

private void logout(){
    login=false;
    if (Session.getActiveSession() != null) {
        Session.getActiveSession().closeAndClearTokenInformation();
    }

    Session.setActiveSession(null);
}

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


  }

Answer 1:

我认为,你的应用程序可以被放置在沙箱模式,而这正是造成他人无法访问您的应用程序。 你可能是应用程序的管理,并与您的帐户甚至可以在沙盒模式访问应用程序

因此,禁用它,使他人您的应用程序的工作。 另外,请检查您是否添加使用密钥库文件生成的keyhash



Answer 2:

关断的sandbox mode在应用设置。

点击这里进入到你的应用信息中心



文章来源: publishing on facebook with sdk 3.0 and android doesn't work