0

我在我的应用程序中设置了与 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;
}


  }
4

2 回答 2

0

sandbox mode在您的应用程序设置中关闭。

单击此处转到您的应用仪表板

于 2013-05-30T12:39:11.087 回答
0

我认为您的应用程序可能处于沙盒模式,这导致其他人无法访问您的应用程序。您可能是应用程序的管理员,即使在沙盒模式下,您也可以使用您的帐户访问应用程序 应用设置页面

所以禁用它以使您的应用程序为其他人工作。还要检查您是否添加了使用您的密钥库文件生成的密钥哈希

于 2013-05-30T12:37:48.780 回答