【问题标题】:android facebook: Not showing my Message in dialogandroid facebook:未在对话框中显示我的消息
【发布时间】:2011-08-18 07:36:08
【问题描述】:

我正在开发 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()); 
        } 

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

谁能指导我..

非常感谢。

【问题讨论】:

  • 我在使用 2012 年 1 月 18 日的最新 SDK 时也遇到了同样的问题,很想知道您是如何解决这个问题的...
  • 忽略我之前的评论。从接受的答案看来,您选择使用 Facebook request 方法而不是 Facebook dialog 方法。

标签: android facebook


【解决方案1】:

消息已被忽略。你可以在这里阅读:https://developers.facebook.com/docs/reference/dialogs/feed/

此字段将在 2011 年 7 月 12 日被忽略 用于预填充用户将输入的文本字段的消息。为了符合 Facebook 平台政策,您的应用程序只能在用户之前手动生成内容的情况下设置此字段在工作流程中。大多数应用程序不应设置此项。

【讨论】:

  • 嗯,这取决于您的应用程序。我不能说最好的解决方案。解决方案只是使用消息属性以外的其他东西。一个示例是发布链接并使用 name 属性。
  • 为什么发帖时总是要求登录,是否可以在墙上发送消息正文,我只能发送链接
【解决方案2】:

使用此代码,它对我有用:

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

    }

【讨论】:

  • 伙计,它在 facebookClient.request 行上给了我 Class Cast 异常,错误是 class cast 异常 java.lang.String。它还表示预期的字节 [],但值为 java.lang.String。任何帮助???
  • 查看我编辑的整个代码:只需简单地实例化这个类
  • 您使用的是哪个存储库。我正在使用这个github.com/facebook/facebook-android-sdk,它没有带有我们参数的 facebook() 构造函数。请更新
  • 这个墙贴对话框需要我们自己定义或在您使用“sharetext”时在 facebook 中预构建..你能分享你的想法吗..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-09-11
  • 1970-01-01
  • 2019-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多