How to post message on facebook wall using Facebook android SDK integrate android app

8.5k views Asked by At

i am developing social app this app integrate to facebook my app related message post to facebook wall i am using facebook sdk in facebook sdk

mPostButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                String message = "Post this to my wall";
                Bundle parameters = new Bundle();        
                parameters.putString("message", message);   
                mAsyncRunner.request("me/feed", parameters, "POST",  new SampleDialogListener());
            }
            });
     mPostButton.setVisibility(mFacebook.isSessionValid() ?
                View.VISIBLE :
                View.INVISIBLE);
    }



   public class SampleDialogListener extends BaseDialogListener implements RequestListener {

            public void onComplete(Bundle values) {
                final String postId = values.getString("post_id");
                if (postId != null) {
                    Log.d("Facebook-Example", "Dialog Success! post_id=" + postId);
                    mAsyncRunner.request(postId, new WallPostRequestListener());
                               } else {
                    Log.d("Facebook-Example", "No wall post made");
                }
            }
 public class WallPostRequestListener extends BaseRequestListener {

        public void onComplete(final String response, final Object state) {
            Log.d("Facebook-Example", "Got response: " + response);
            String message = "<empty>";
            try {
                JSONObject json = Util.parseJson(response);
                message = json.getString("message");
            } catch (JSONException e) {
                Log.w("Facebook-Example", "JSON Error in response");
            } catch (FacebookError e) {
                Log.w("Facebook-Example", "Facebook Error: " + e.getMessage());
            }
            final String text = "Your Wall Post: " + message;
            Example.this.runOnUiThread(new Runnable() {
                public void run() {
                    mText.setText(text);
                }
            });
        }

i am using this code is not working to post message my intension is userlogin facebook my string is open just publish wall post

2

There are 2 answers

0
Farhan On BEST ANSWER

As i am also a learner at this stage, Can you tell me why are you using sample dialog listener in mAsyn.request("me/feed",.....).....

What is the error???

I think, if you are logged in, just call wallpostlistener in mAsync.request("me/feed",...,new WallPost....)... this is what i do in my application.

0
Daniel Ruben Odio-Paez On

@narasimha if you don't want to deal with the intricacies of the Facebook SDK, you can check Socialize out. http://www.GetSocialize.com with full feature list at http://go.GetSocialize.com/features. Good luck!

DROdio