2012-11-14 85 views
1

我需要发布位图到Facebook墙以及消息和url链接。facebook API添加照片

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参数,为什么它不起作用?

回答

0

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