如何为单个Facebook消息帖子提供不同的多个url超链接

时间:2013-03-18 09:56:56

标签: android facebook url post hyperlink

我发送消息到Facebook墙我的帖子包含图像和标题和标题和说明。我想给我的单个帖子的不同项目提供不同的超链接。我成功发送在Facebook墙上的帖子。但是不能给出多个url超链接。我的代码在这里

 Bundle postParams = new Bundle();
        postParams.putString(Facebook.TOKEN, facebook.getAccessToken());
        postParams.putString("name", "LangGuage");
        postParams.putString("href", "http://www.facebook.com");
        postParams.putString("caption",msg);
        postParams.putString("picture",url1);
        postParams.putString("description","Powered by::Hunka Technology Pvt. Ltd.");

        postParams.putString("link", "http://www.hunkatech.com");

我的图片,邮件和标题都有相同的链接。我们可以为所有人提供不同的网址。

更新:我也试过这样做但得到这个:{“error”:{“message”:“(#100)缺少消息或附件”,“输入”:“OAuthException”,“code”:100} }

 JSONObject attachment = new JSONObject();

            attachment.put(Facebook.TOKEN, facebook.getAccessToken());
            attachment.put("message", "hi ");
            attachment.put("name", "LangGuage");
            attachment.put("link", "http://www.facebook.com");
            attachment.put("caption", msg);


            JSONObject media = new JSONObject();
            media.put("type", "image");
            media.put("picture", url1);
            media.put("link","http://www.google.com");
            attachment.put("media", new JSONArray().put(media));



            JSONObject properties = new JSONObject();

            JSONObject prop1 = new JSONObject();


            prop1.put("text", "Powered by::Hunka Technology Pvt. Ltd.");
            prop1.put("link", "http://www.hunkatech.com");
            properties.put("Get the App for free", prop1);


            attachment.put("properties", properties);

            Log.d("FACEBOOK", attachment.toString());

            Bundle params = new Bundle();
            params.putString("attachment", attachment.toString());

            String res = facebook.request("me/feed", params, "POST");
            System.out.println("----resp" + res);

是否有可能从任何方面......

1 个答案:

答案 0 :(得分:1)

首先,href不存在post字段,但这只会被忽略。

你无法得到你想要的东西。帖子可以包含:

  • 允许任意数量链接的消息,
  • 只有一个字幕链接(标题有标题,说明,图片和网址)。

此示例代码:

Bundle postParams = new Bundle();

postParams.putString(Facebook.TOKEN, facebook.getAccessToken());

/* Caption information (to highlight one link only) */
postParams.putString("caption", "Stack Overflow");
postParams.putString("picture", "http://myrrix.com/wp-content/uploads/2012/06/stackoverflow.png");
postParams.putString("description","A language-independent collaboratively edited question and answer site for programmers.");
postParams.putString("name", "stackoverflow.com"); //Name of the link
postParams.putString("link", "http://stackoverflow.com");
/* End of the caption information */

response = facebook.request("me/feed", postParams, "POST");

...结果:

A post link with several links

您可以在上图中看到的部门实际上是一个链接,这是一个由link字段指定的链接。所有其他字段只是文字和图片信息。在HTML中它将是:

<a href="http://stackoverflow.com"><div id="caption"> ... </div></a>