Facebook SDK 4+ - 以编程方式发布到我自己的墙上(Android)

时间:2015-06-12 05:22:54

标签: android facebook-sdk-4.0

有人可以告诉我一种如何在没有共享对话框的情况下以编程方式发布墙贴的方法。我知道用户的帐户首次连接到我们的应用时应该询问的权限。但在用户提供权限后,我应该能够发布更新。 我认为publish_stream和publish_actions是我需要包含的。

1 个答案:

答案 0 :(得分:0)

可能有用:

            AccessToken accessToken = AccessToken.getCurrentAccessToken();

            Bundle postParams = new Bundle();
            postParams.putString("name", "yourTitle");
            postParams.putString("caption", "yourAppName");
            postParams.putString("description", "yourText");
            postParams.putString("message", "yourComment");
            postParams.putString("link", "yourLink");
            postParams.putString("picture", "yourImagUrl");

            GraphRequest request = new GraphRequest(accessToken, "me/feed",
                    postParams, HttpMethod.POST, null);

            GraphResponse response = request.executeAndWait();//or executeAsync() see documentation


            FacebookRequestError error = response.getError();
            if (error != null) {
                //do something with error
                return;
            }
            //do something with response