簡體   English   中英

如何使用Android的最新facebook SDK在Facebook上發布圖像和URL?

[英]How to publish image and URL on Facebook using latest facebook SDK for Android?

我想創建一個Facebook對話框,如此鏈接的最后一張圖片所示。 但我無法看到默認消息,也無法看到圖像。 我借助此鏈接編寫了此代碼。

這是相同的代碼:

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());


    }

我錯過了什么?

試試這個Snippet發布圖片以及其他詳細信息:

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());
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM