Facebook SDK 4+ - Post to my own wall programmatically (Android)

794 Views Asked by At

Can someone tell me a way of how to publish a wall post programmatically without the share dialog. I'm aware about the permissions that should be asked when a user's account is first connected to our app. But after the user has provided the permissions, i should be able to post updates. publish_stream and publish_actions i suppose are the ones that i need to include.

1

There are 1 best solutions below

0
On

May be this be useful:

            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