Show facebook share dialog

一世执手 提交于 2019-12-13 08:47:23

问题


hi i am currently working on facebook sharing. i already have succeeded in posting particular params to facebook however what i did is to post it without even showing what will the post look like.. i was planning to show a share dialog but i cant seem to find a good guide on how i can implement it..

here's how i post

public void loginAndPostToWall(){
         facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());
    }

    public void postToWall(String message){
        Bundle parameters = new Bundle();
                parameters.putString("message", "message");
                parameters.putString("link", "www.example.com");
                parameters.putString("name", "my name");
                parameters.putString("description", "Try me!");
                try {
                    facebook.request("me");
            String response = facebook.request("me/feed", parameters, "POST");
            Log.d("Tests", "got response: " + response);
            if (response == null || response.equals("") ||
                    response.equals("false")) {
                showToast("Blank response.");
            }
            else {
                showToast("Message Posted to your Wall");
            }
            finish();
        } catch (Exception e) {
            showToast("Failed to post to wall!");
            Log.v("hey", "exception:" + e);
            e.printStackTrace();
            finish();
        }
    }

any hints or guides will do.. thank you


回答1:


The following method will simply post to the wall like this:

Before posting to the wall, it will ask "What is in your mind" before posting. You can enter some text in that and then post. This is working perfectly for me.

public void SharetoWall() {
            Bundle params = new Bundle();
            params.putString("name", "test title");
            params.putString("description", "test desc");       
            params.putString("link", "some url");
            try{

                params.putString("picture", valuesProductImages.get(0));

            }catch(Exception e){

            }

            facebook.dialog(getParent(), "feed", params, new DialogListener() {

                public void onFacebookError(FacebookError e) {

                }

                public void onError(DialogError e) {

                }

                public void onComplete(Bundle values) {

                }

                public void onCancel() {

                }
            });

        }


来源:https://stackoverflow.com/questions/18907788/show-facebook-share-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!