如何在Facebook上发布消息而不打开任何对话框?

时间:2013-11-28 07:56:22

标签: android facebook

我想在没有使用原生Facebook安卓应用的开放式对话框的情况下在Facebook上发布消息。 我正在使用facebook sdk 3.5.2。 我已成功在墙上发布消息。

我正面临一些问题。

1)如果我从本地Facebook应用程序注销。然后它将消息发布到以前用户的Facebook墙壁&它不要求认证。

2)如果用户使用Facebook本机应用程序中的其他帐户登录,它仍会发送消息 以前的帐户(首次通过应用程序登录)。不要求身份验证。

代码: -

 Session.openActiveSession(this, true, new Session.StatusCallback() {

                // callback when session changes state
                @Override
                public void call(Session session, SessionState state, Exception exception) {
                    if (session.isOpened()) {

                        new messagePostAsyn().execute(session);

                    }
                }
              });

方式:

 private void postStatus(final Session session, String message) {


    Bundle _postParameter = new Bundle();
    _postParameter.putString("name", message);

    _postParameter.putByteArray("picture", bytes);
    _postParameter.putString("caption", "To help....");
    _postParameter.putString("description", "Testing...");
    Request request = new Request(session, "me/photos", _postParameter,
            HttpMethod.POST, new Callback() {

                @Override
                public void onCompleted(Response response) {
                    // TODO Auto-generated method stub
                    System.out.println("response......" + response);

                }
            });



    Request.executeBatchAsync(request);


}

此方法用于messagePostAsyn()类。

1 个答案:

答案 0 :(得分:0)

试用此代码:

public void postToWall(String message) {
    Bundle params = new Bundle();
    params.putString("message", message);

    // Uses the Facebook Graph API
    try {
        facebook.request("/me/feed", params, "POST");
        this.finish();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
相关问题