【问题标题】:facebook API add photofacebook API 添加照片
【发布时间】:2012-11-14 16:34:12
【问题描述】:

我需要在 Facebook 墙上发布位图以及消息和 url 链接。

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

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参数,为什么不行?

【问题讨论】:

    标签: android facebook facebook-graph-api post


    【解决方案1】:

    好的,我找到了问题 (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 参数只字未提。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-09
      • 2020-03-19
      • 2011-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多