我正在使用新的 FB Android SDK 3.0 将照片发布到 FB。我现在正在寻找一种方法来设置更多参数,而不仅仅是图像本身和简单的文本。我尝试了很多不同的参数,但似乎没有一个能起作用。
我想做的是添加一个链接、一个图标,如果可能的话,在“赞”和“评论”链接旁边添加一个自定义链接项。
这是来自 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();
帖子看起来像这样:
最佳答案
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 中测试
4。时间轴预览
关于android - 将照片发布到 Facebook 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14033911/