2012-11-14 4 views
1

메시지 및 URL 링크와 함께 Facebook에 Bitmap을 게시해야합니다.facebook API add photo

source, message, place, no_story : https://developers.facebook.com/docs/reference/api/user/#photos에 따르면

, 페이스 북 앨범에 사진을 추가 할 4 개 매개 변수가 있습니다.

그러나, 나는이 같은 코드를 사용하는 것이 좋습니다했다 :

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 매개 변수가 없습니다 (위 참조). 이 link 매개 변수를 사용하는 것이 불가능하면

  2. , SLComposeViewController 클래스 (http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/SLComposeViewController_Class/Reference/Reference.html) 어떻게 작동합니까? 그것은 - (BOOL)addURL:(NSURL *)url 방법이 있습니다.

  3. link 매개 변수를 사용할 수 있다면 왜 작동하지 않습니까?

답변

0

좋아, 질문 (2) 및 (3)에 대한 답변을 찾았습니다. 매우 간단한 것으로 나타나 단지 message에 추가, link를 사용하지 않는 : 내 질문 (1)에 관해서는

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

를, 나를 위해 여전히 불분명하다 : 왜 postParams.putByteArray("source", data);의 미세 대신 postParams.putByteArray("photo", data); 작동합니까? 설명서에 photo 매개 변수에 대한 내용이 없습니다.