1

我正在使用新的 FB Android SDK 3.0 将照片发布到 FB。我现在正在寻找一种方法来设置更多参数,而不仅仅是图像本身和简单的文本。我尝试了很多不同的参数,但它们似乎都没有做某事。

我想做的是添加一个链接、一个图标,如果可能的话,在 Like 和 Comment 链接旁边添加一个自定义链接项。

以下是来自 twitter 的图标和自定义链接项的示例:

在此处输入图像描述

这是我目前使用的代码:

    byte[] data = get binary image data;

    Bundle postParams = new Bundle();
    postParams.putString("name", "Image text");
    postParams.putByteArray("picture", data);

    // All these parameters do nothing...
    postParams.putString("icon", "http://www.myimage.com/image.png");
    postParams.putString("message", "XXX");
    postParams.putString("caption", "Build great social apps and get more installs.");
    postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
    postParams.putString("link", "https://developers.facebook.com/android");

    Request request = new Request(Session.getActiveSession(), "me/photos", postParams, HttpMethod.POST);
    Response r = request.executeAndWait();

帖子看起来像这样:

在此处输入图像描述

4

1 回答 1

2

1.添加图标

您可以从应用程序的仪表板管理图标:https ://developers.facebook.com/apps/APP_ID/appdetails

2.添加动作链接

你可以一个“自定义链接”实际上是一个“动作”。

您在 Twitter 帖子中看到的“操作”是使用表中的actions数组完成的Post

帖子上可用操作的列表(包括评论、点赞和可选的应用指定操作)

因此,如果您真的想在Like · Comment附近添加此操作,您唯一的选择是创建 aPostFeed而不是 a Photo

这是一个先验的工作代码:

postParams.putString("message", "XXX");
postParams.putString("caption", "developers.facebook.com");
postParams.putString("description", "A tool to help you learn and browse the Facebook Graph API.");
postParams.putString("actions", "[{
       'name':'Test a simple Graph API call!',
       'link':'https://developers.facebook.com/tools/explorer?method=GET&path=me'
       /* ^ This link must direct to the application's connect or canvas URL. 
          You'll get an error otherwise. */
    }]"
);
postParams.putString("type", "photo");
postParams.putString("link", "https://developers.facebook.com/tools/explorer/");
postParams.putString("picture", "http://blog.programmableweb.com/wp-content/ishot-44.png");

Request request = new Request(Session.getActiveSession(), "me/feed", postParams, HttpMethod.POST);

3. 在 Graph API Explorer 中测试

在 Graph API Explorer 中测试

4.时间线预览

时间线预览

于 2012-12-26T16:55:16.100 回答