2011-11-30 5 views
0

이 예제를 시도 : Android how to post picture to friend's wall with facebook android sdkAndroid : android sdk가있는 친구의 담벼락에 사진/비디오를 게시하는 방법?

하지만 작동하지 않습니다. 여기에 내 코드 :

String response = Utility.mFacebook.request((userID == null) ? "me" : userID); 

      final Bundle params = new Bundle(); 
      params.putString("message", "test"); 
      params.putString("caption", "test"); 
      params.putString("picture", "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"); 

      response = Utility.mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST"); 

친구의 벽에 비디오/사진을 게시 할 수있는 샘플 코드가 있습니까?

답변

0

이것은 벽에 사진을 게시하는 데 사용하는 방법입니다. URL에서 사진을 게시하지만 사진 대신 바이트 []를 삽입하도록 변경할 수 있습니다. 메시지가 그림 위에 나타나고 캡션이 그림의 오른쪽에 나타납니다.

protected void postPicToWall(String userID, String msg, String caption, String picURL){ 
    try { 
     if (isSession()) { 
      String response = mFacebook.request((userID == null) ? "me" : userID); 

     Bundle params = new Bundle(); 
     params.putString("message", msg); 
     params.putString("caption", caption); 
     params.putString("picture", picURL); 

     response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");  

     Log.d("Tests",response); 
     if (response == null || response.equals("") || 
       response.equals("false")) { 
      Log.v("Error", "Blank response"); 
     } 
    } else { 
     // no logged in, so relogin 
     Log.d(TAG, "sessionNOTValid, relogin"); 
     mFacebook.authorize(this, PERMS, new LoginDialogListener()); 
    } 
}catch(Exception e){ 
    e.printStackTrace(); 
    } 
} 

다음 라인을

params.putString ("사진"을 picURL)로 교체 PIC의 URL 대신 바이트 []를 작성하는 단계;

params.putByteArray ("picture", getIntent(). getExtras(). getByteArray ("data"));

여기서 data는 사용자의 배열입니다.

관련 문제