android facebook:没有在对话框中显示我的消息

时间:2011-08-18 07:36:08

标签: android facebook

我正在使用facebook android应用程序,但我面临一个问题

我使用以下示例
Android/Java -- Post simple text to Facebook wall?

所以问题是一切都在这里工作正常,对话框等等但当它打开屏幕上传我在这里设置的Walla消息时

        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()); 
        } 

它没有显示我在对话框中写的消息。是什么问题

任何人都可以指导我..

非常感谢。

2 个答案:

答案 0 :(得分:7)

消息已被忽略。您可以在此处阅读:https://developers.facebook.com/docs/reference/dialogs/feed/

  

此字段将在2011年7月12日被忽略预填充用户将键入的文本字段的消息。要符合Facebook平台策略,您的应用程序可能仅在用户先前手动生成内容时设置此字段在工作流程中。大多数应用程序不应该设置它。

答案 1 :(得分:0)

使用此代码,它适合我:

                    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");

希望有所帮助......

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;     
        }

    }
相关问题