android - 将照片发布到 Facebook 参数

标签 android facebook facebook-graph-api

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

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

这是来自 Twitter 的图标和自定义链接项目的示例:

enter image description here

这是我目前使用的代码:

    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();

帖子看起来像这样:

enter image description here

最佳答案

1。添加图标

您可以从 app's dashboard 管理图标: https://developers.facebook.com/apps/APP_ID/appdetails

2。添加操作链接

“自定义链接”实际上是一个“操作”。

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

A list of available actions on the post (including commenting, liking, and an optional app-specified action)

因此,如果您真的想在赞·评论附近添加此操作,您唯一的选择是创建一个 Post进入 Feed 而不是 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 中测试

Test in the Graph API Explorer

4。时间轴预览

Timeline preview

关于android - 将照片发布到 Facebook 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14033911/

相关文章:

.net - 如何从 android 调用 .NET Web 服务?

android - 从第 3 方库导入类。安卓工作室 3.1, Gradle 3.1

java - 如何使用 android facebook sdk 访问用户提要/帖子

javascript - Facebook APP [和 js api] 不显示任何 friend

java - 转换包含嵌套 JSONString 的 JSONObject 时出现 JsonMappingException

android - java.lang.IllegalStateException : Expected BEGIN_OBJECT but was STRING at line 1 column 错误

Android - 如何使用 Intent 和 KML 打开谷歌地图?

facebook -/me/home 检索新闻提要的过时 View

javascript - 控制 Facebook iFrame 应用程序父框架的滚动位置

c# - Windows Phone 8 Facebook 认证