简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM