繁体   English   中英

Facebook API添加照片

[英]facebook API add photo

我需要将Bitmap以及消息和URL链接发布到Facebook墙上。

根据https://developers.facebook.com/docs/reference/api/user/#photos ,有4个参数可将照片添加到Facebook相册:

sourcemessageplaceno_story

但是,建议我使用如下代码:

Bitmap bm = ...;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(CompressFormat.JPEG, 100, baos);
final byte[] data = baos.toByteArray();
Bundle postParams = new Bundle();

postParams.putByteArray("photo", data);
postParams.putString("message", "My message here");
postParams.putString("link", "http://www.google.com");

Request request = new Request(session, "me/photos", postParams, HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();

...,并且此代码可以正常工作,但它不会在墙上显示链接(“ http://www.google.com”)。

我有三个问题:

  1. 为什么postParams.putByteArray("photo", data)起作用? 根据文档,没有photo参数(请参见上文)。

  2. 如果不可能使用link参数,SLComposeViewController类(http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/SLComposeViewController_Class/Reference/Reference.html)如何工作? 它具有- (BOOL)addURL:(NSURL *)url方法。

  3. 如果可以使用link参数,为什么它不起作用?

好的,我找到了问题(2)和(3)的答案。 它看起来非常简单:不使用link ,只需将其附加到message

postParams.putByteArray("photo", data);
postParams.putString("message", "My message here" + " " + "http://www.google.com");
//postParams.putString("link", "http://www.google.com");

至于我的问题(1),对我来说还不清楚:为什么postParams.putByteArray("photo", data); 工作正常,而不是postParams.putByteArray("source", data); 该文档对photo参数一无所知。

暂无
暂无

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

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