5

I am working on facebook android application but there is one problem i am facing

i am using the following example
Android/Java -- Post simple text to Facebook wall?

so the problem is that everything works here fine, the dialogs etc etc but When it open the screen to upload Walla Message that i have setted up here

        try 
        { 
            System.out.println("*** IN TRY ** ");
            Bundle parameters = new Bundle(); 
            parameters.putString("message", "this is a test");// the message to post to the wall 
            facebookClient.dialog(this, "stream.publish", parameters, this);// "stream.publish" is an API call 
        } 
        catch (Exception e) 
        { 
            // TODO: handle exception 
            System.out.println(e.getMessage()); 
        } 

It does not show me my Message written in the dialog. Whats the problem with that

can anybody Guide me please..

Thanks alot.

Community
  • 1
  • 1
Shah
  • 4,990
  • 10
  • 48
  • 70
  • I have this same problem also using the latest SDK dated January 18 2012 and would be curious to know how you got around it... – Adil Hussain Feb 09 '12 at 18:56
  • Ignore my previous comment. From the accepted answer looks like you have opted to use the Facebook `request` method rather than the Facebook `dialog` method. – Adil Hussain Feb 09 '12 at 18:59

2 Answers2

7

Message has been ignored. You can read about it here: https://developers.facebook.com/docs/reference/dialogs/feed/

This field will be ignored on July 12, 2011 The message to prefill the text field that the user will type in. To be compliant with Facebook Platform Policies, your application may only set this field if the user manually generated the content earlier in the workflow. Most applications should not set this.

David Olsson
  • 8,085
  • 3
  • 30
  • 38
  • 1
    Well, it depends on your application. I can't say the best solution. The solution is just to use something else than the message attribute. One example would be to post a link and use the name attribute. – David Olsson Aug 18 '11 at 08:04
  • why it always ask for login while posting, and is it possible to send message body on wall ,i am able to send only link – Srishti Roy Dec 28 '15 at 12:01
0

Use this code , it working for me :

                    Bundle parameters = new Bundle();
                    parameters.putString("message",sharetext.getText().toString());// the message to post to the wall
                    //facebookClient.dialog(Jams.this, "stream.publish", parameters, this);// "stream.publish" is an API call
                    facebookClient.request("me/feed", parameters, "POST");

Hope it helps..

Edited:



 public class FacebookActivity implements DialogListener
    {

        private Facebook facebookClient;
        private LinearLayout facebookButton;



       public FacebookActivity(Context context) {

           facebookClient = new Facebook();
           // replace APP_API_ID with your own
           facebookClient.authorize(Jams.this, APP_API_ID,
               new String[] {"publish_stream", "read_stream", "offline_access"}, this);

       }

        @Override
        public void onComplete(Bundle values)
        {

            if (values.isEmpty())
            {
                //"skip" clicked ?

            }

            // if facebookClient.authorize(...) was successful, this runs
            // this also runs after successful post
            // after posting, "post_id" is added to the values bundle
            // I use that to differentiate between a call from
            // faceBook.authorize(...) and a call from a successful post
            // is there a better way of doing this?
            if (!values.containsKey("post_id"))
            {
                try
                {
                    Bundle parameters = new Bundle();
                    parameters.putString("message",sharetext.getText().toString());// the 

message to post to the wall
                    //facebookClient.dialog(Jams.this, "stream.publish", parameters, 

this);// "stream.publish" is an API call
                    facebookClient.request("me/feed", parameters, "POST");
                    sharetext.setText("");
                    Toast.makeText(Jams.this,"Message posted 

successfully.",Toast.LENGTH_SHORT).show();

                }
                catch (Exception e)
                {
                    // TODO: handle exception
                   // System.out.println(e.getMessage());
                }

            }

        }

        @Override
        public void onError(DialogError e)
        {       
            return;
        }

        @Override
        public void onFacebookError(FacebookError e)
        {   
            return;
        }

        @Override
        public void onCancel()
        {      
            return;     
        }

    }
Uday
  • 5,933
  • 9
  • 44
  • 76
  • 1
    buddy it is giving me Class Cast exception on facebookClient.request line the error is class cast exception java.lang.String. it also says that expected byte[] but the value is java.lang.String. Any Help ??? – Shah Aug 18 '11 at 08:37
  • See my edited entire code : Just simply instantiate this class – Uday Aug 18 '11 at 08:43
  • Which repository are u using . I am using this one https://github.com/facebook/facebook-android-sdk and it does not have facebook() consructor withour parameters. Please update – Shah Aug 18 '11 at 10:30
  • this wall post dialog need to define by ourself or its pre build in facebook as you are using "sharetext".. can you share your idea.. – kamal_tech_view Jul 06 '12 at 09:20