简体   繁体   English

使用Facebook SDK 3.0将图片添加到墙上帖子吗?

[英]Add picture to wall post using Facebook SDK 3.0?

I want to post a message on my wall, adding a PNG image ( not a URL), as shown below. 我想在墙上张贴一条消息,添加一个PNG图像( 而不是 URL),如下所示。 Everything works except that no image is posted. 一切正常,但不发布任何图像。 Is this even supported? 甚至支持吗? Is there a size limit? 有尺寸限制吗?

Bundle params = new Bundle();
params.putString("access_token", session.getAccessToken());
params.putString("description", message);
params.putString("caption", caption);
params.putString("name", name);
params.putString("link", link);

// Does not work:
// params.putByteArray("photo", pngByteArray);
// params.putByteArray("picture", pngByteArray);

WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this,
   Session.getActiveSession(),
   params)) /* ... */

As you can see, I'm using the FeedDialogBuilder class to let the user confirm the wall post. 如您所见,我正在使用FeedDialogBuilder类让用户确认留言。

This code is working for me: 这段代码为我工作:

Bundle params = new Bundle();
params.putString("access_token", session.getAccessToken());
params.putString("description", message);
params.putString("caption", caption);
params.putString("name", name);
bundle.putByteArray("picture", byte);
String response = facebook.request("me/photos",bundle,"POST");

hope it will help you. 希望对您有帮助。

You need one more field in it, 您还需要一个字段,

params.putString("app_id", "Your_App_ID_Required"); params.putString(“ app_id”,“ Your_App_ID_Required”);

it worked for me after I added this field.. 在我添加此字段后,它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM