【问题标题】:Setting text in facebook statuc from native android application从本机 android 应用程序在 facebook statuc 中设置文本
【发布时间】:2012-12-06 11:31:13
【问题描述】:

我正在尝试从我的应用程序中设置 facebook 状态中的文本,但它没有复制到 facebook 帖子对话框的状态对话框中。对话框为 fb 正确打开,但消息未复制到状态框中。谢谢 我的代码是:

facebook = new Facebook("my_app_id");
        Bundle parameters = new Bundle();
        parameters.putString("message", "HI there");


        facebook.dialog(this, "feed", parameters,
                new PostDialogListener());

PostDialogListener class
                public  class PostDialogListener implements DialogListener {
        @Override
        public void onFacebookError(FacebookError e) {
            e.printStackTrace();
        }
        @Override
        public void onComplete(Bundle values) {

            final String postId = values.getString("post_id");
            if (postId != null) {

            } else {

            }
        }

        @Override
        public void onError(DialogError e) {

            e.printStackTrace();
        }

        @Override
        public void onCancel() {
        }
    }

【问题讨论】:

  • 点击“发布”后在 Facebook 上发布的文字是什么?
  • 我必须手动写文本是状态框才能发布。我希望它来自我的应用程序
  • @sanjeev 看看我的回答,它会解决你的问题。

标签: android post status


【解决方案1】:

试试这个代码,看看它是否适合你。对我来说,它完美无缺,因为我想发布自定义消息。

new Thread(){
        public void run(){
            Looper.prepare();
            Bundle parameters = new Bundle();

                parameters.putString("message", "your_message_here");

            parameters.putString("caption", "your_caption");
            try {
                mFacebook.request("me");
                String response = mFacebook.request("me/feed", parameters, "POST");
                Log.d("Tests", "got response: " + response);
                if (response == null || response.equals("")
                        || response.equals("false") || response.startsWith("{\"error\"")) {
                    mActivity.runOnUiThread(failRunnable);
                } else {
                    mActivity.runOnUiThread(successRunnable);
                }
            } catch (Exception e) {
                showToast("Failed to post to wall!");
                e.printStackTrace();
            }
        }
    }.start();

mFacebook 是我的 Facebook 对象。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-22
    • 1970-01-01
    相关资源
    最近更新 更多