2012-01-18 50 views
0

我想創建一個facebook對話框,如link的最後一張圖所示。但我無法看到默認信息,也無法看到圖像。我在這個link的幫助下編寫了這段代碼。如何在Facebook上使用最新的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

謝謝venky ...但我仍然無法看到默認消息 – Nik 2012-01-18 14:30:18

+0

默認消息是指? – Venky 2012-01-18 14:31:07

+0

我的意思是通過 - attachment.put(「message」,「Messages」)發送的消息;我無法在發佈對話框中看到此消息..它是一個沒有消息的空白框......但允許用戶輸入..我想顯示消息以及希望允許用戶鍵入在 – Nik 2012-01-18 14:34:11

相關問題