在android中的Facebook墙上分享链接

时间:2011-09-06 05:25:21

标签: android facebook

任何人都可以帮助我了解如何在Facebook墙上分享链接吗?

公共类SampleDialogListener扩展了BaseDialogListener {

        public void onComplete(Bundle values) {
            final String postId = values.getString("post_id");///////
            Log.d("Facebook-Example", "Dialog Success! post_id=" + postId);

            if (postId != null) {
                Log.d("Facebook-Example", "Dialog Success! post_id=" + postId);
                mAsyncRunner.request(postId, new WallPostRequestListener());
                mDeleteButton.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        mAsyncRunner.request(postId, new Bundle(), "DELETE",
                                new WallPostDeleteListener(), null);
                    }
                });
                mDeleteButton.setVisibility(View.VISIBLE);
            } else {
                Log.d("Facebook-Example", "No wall post made");
            }
        }
    }

我得到了post_id的空值..

2 个答案:

答案 0 :(得分:1)

您可以使用以下代码

来实现此目的
Bundle parameters = new Bundle();
parameters.putString("message", "Test Photo");
parameters.putString("attachment", "{\"name\":\"My Test link\","
+"\"href\":\""+"http://www.google.com"+"\"}");
facebookClient.dialog(this, "stream.publish", parameters, this);

答案 1 :(得分:0)

要共享消息,只需添加一个参数:

params.putString("caption", "Test Photo");