-1

在我的 android 应用程序中,我使用 Facebook Api 在他/她的墙上发布消息。它工作正常,没有任何问题。现在我尝试在其中发布带有 html 链接的消息。该消息已发布在 Facebook 墙上,但 html 链接不起作用。它看起来像普通的文本。这是我试图用代码在 Facebook 墙上发布的消息

private String Facebook = "<a href=https://www.facebook.com/>Facebook</a>";

Message = "Hi"+Html.fromHtml(Facebook);

我做错什么了吗。

编辑

我想在脸书墙上有这样的

嗨,EveryOne Facebook是一个非常好的社交网站。

谢谢你们的帮助。

4

2 回答 2

0

试试这个片段来添加 html 链接:

    Bundle parameters = new Bundle();
    JSONObject attachment = new JSONObject();
    try {
            attachment.put("message", "Messages");
            attachment.put("name", "Message");
            attachment.put("href", "http://www.facebook.com");
    } catch (JSONException e) {}
    parameters.putString("attachment", attachment.toString());
    facebook.request(parameters);       
于 2012-07-16T10:26:01.067 回答
0
// put this code in your button click event listener     
facebook = new Facebook("your facebook id");

                    mAsyncRunner = new AsyncFacebookRunner(facebook);
                    facebook.authorize(this, new String[]
                    { "publish_stream", "offline_access" }, -1,

                    new DialogListener()
                    {
                        public void onComplete(Bundle values)
                        {
                            Log.e("tag", "Values returned by Bundle ====> " + values.toString());
                            fbImageSubmit(facebook, "", "caption", "description", "name", "www.google.com");
                        }

                        public void onFacebookError(FacebookError error)
                        {

                        }

                        public void onError(DialogError e)
                        {

                        }

                        public void onCancel()
                        {

                        }
                    });

//add method into your class

    private void fbImageSubmit(Facebook fb, String imageurl, String caption, String description, String name, String linkurl)
        {
            if (fb != null)
            {
                if (fb.isSessionValid())
                {
                    Bundle b = new Bundle();
    //              b.putString("picture", "");
                    b.putString("caption", "");
                    b
                            .putString(
                                    "description",
                                    "test");
                    b.putString("name", "Hi Friends, I am using the your app name app for Android!");
                    b.putString("link", "https://market.android.com/details?id="+this.getApplication().getPackageName().toString());
                    try
                    {
                        String strRet = "";
                        strRet = fb.request("/me/feed", b, "POST");
                        JSONObject json;
                        try
                        {
                            json = Util.parseJson(strRet);
                            if (!json.isNull("id"))
                            {
                                Log.i("Facebook", "Image link submitted.");
                            }
                            else
                            {
                                Log.e("Facebook", "Error: " + strRet);
                            }
                        } catch (FacebookError e)
                        {
                            Log.e("Facebook", "Error: " + e.getMessage());
                        }
                    } catch (Exception e)
                    {
                        Log.e("Facebook", "Error: " + e.getMessage());
                    }
                }
            }
        }
于 2012-07-16T11:06:23.697 回答