2012-01-18 2 views
0

link의 마지막 이미지에 표시된대로 페이스 북 대화 상자를 만들고 싶습니다. 그러나 기본 메시지를 볼 수 없으며 이미지를 볼 수도 없습니다. 나는이 link 세부 사항의 도움으로이 코드를 작성했습니다.안드로이드 용 최신 facebook SDK를 사용하여 페이스 북에 이미지 및 URL을 게시하는 방법

내가 뭘 놓친 거지 같은

public void postToWall(String message) { 

    Bundle parameters = new Bundle(); 
    parameters.putString("method", "stream.publish"); 

    JSONObject attachment = new JSONObject(); 

    try { 

     attachment.put("app_id", APP_ID); 
     attachment.put("href", MY_URL); 
     attachment.put("picture", MY_PICTURE_URL); 
     attachment.put("name", NAME_FOR_URL); 
     attachment.put("caption", CAPTION_FOR_URL); 
     attachment.put("description", DESCRIPTION_FOR_URL); 
     attachment.put("message", MESSAGE); 

    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 

    parameters.putString("attachment", attachment.toString()); 
    facebook.dialog(this, "stream.publish",parameters, new TestUiServerListener()); 


    } 

의 코드 스냅 샷 뭔가

여기

입니다 실종 ... ... 난 붙어입니다 도와주세요

라즈

답변

2

이 스 니펫을 이미지 게시와 함께 추가 세부 정보 :

private void post_facebook() { 
    Bundle parameters = new Bundle(); 
    parameters.putString("method", "stream.publish"); 

    JSONObject attachment = new JSONObject(); 

      // for adding image to Dialog  
    try { 
     JSONObject media = new JSONObject(); 
     media.put("type", "image"); 
     media.put("src", "Any Image Link"); 
     media.put("href", "Any Image Link"); 
     attachment.put("media", new JSONArray().put(media)); 
    } catch (JSONException e1) { 
    } 

      // End if Image attachment 

      // for adding Message with URL link 
    try { 
     attachment.put("message", "Messages"); 
     attachment.put("name", "Check out"); 
     attachment.put("href", "http://www.google.com"); 
    } catch (JSONException e) { 
    } 

    parameters.putString("attachment", attachment.toString()); 
    authenticatedFacebook.dialog(Settings_View.this, "stream.publish",parameters, new TestUiServerListener()); 
} 
+0

감사합니다.하지만 기본 메시지를 볼 수 없습니다. – Nik

+0

기본 메시지는 무엇을 의미합니까? – Venky

+0

나는 attachment.put ("message", "Messages")를 통해 전송 된 메시지를 의미합니다. 게시 대화 상자에서이 메시지를 볼 수 없습니다. 메시지가없는 빈 상자 ... 그러나 사용자가 입력 할 수 있습니다. 메시지를 표시하고 사용자가 입력 할 수있게하려는 경우 – Nik

관련 문제