0

我想使用 android facebook sdk 3.0.2 在 facebook 上分享一些文本

我试过这个:

Bundle params = new Bundle();
                params.putString("caption", "test");
                params.putString("message", "test");
                params.putString("link", "https://www.google.com");
                // params.putString("picture", "picture_url");

                Request request = new Request(Session.getActiveSession(),
                        "me/feed", params, HttpMethod.POST);
                request.setCallback(new Request.Callback() {
                    @Override
                    public void onCompleted(Response response) {
                        if (response.getError() == null) {
                            Toast.makeText(About.this, "Successfully posted",
                                    Toast.LENGTH_LONG).show();
                        } else
                            Toast.makeText(About.this, "An Error Has Happened",
                                    Toast.LENGTH_SHORT).show();
                    }
                });
                request.executeAsync();
            }

吐司总是在打印an error has happened

任何帮助,将不胜感激

4

1 回答 1

1
    Session s = Session.getActiveSession();

Request request = Request.newStatusUpdateRequest(s, "your msg", new Request.Callback() 
    {
        @Override
        public void onCompleted(Response response)
        {
            if(response.getError()==null) 
                Toast.makeText(MainActivity.this, "Status updated successfully", Toast.LENGTH_LONG).show();

        }
    });
    request.executeAsync();

如果您已登录并提供了所有权限,这将发布您的消息。

于 2013-07-31T10:08:11.840 回答