【问题标题】:How to publish image and URL on Facebook using latest facebook SDK for Android?如何使用最新的 Android 版 Facebook SDK 在 Facebook 上发布图片和 URL?
【发布时间】:2012-01-18 14:06:15
【问题描述】:

我想创建一个 Facebook 对话框,如 link 的最后一张图片所示。但我看不到默认消息,也看不到图像。我在link 的帮助下编写了这段代码。

这是相同的代码:

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


    }

我错过了什么?

【问题讨论】:

    标签: android facebook sdk integration publish


    【解决方案1】:

    试试这个用于发布图片的片段以及其他详细信息:

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

    【讨论】:

    • 谢谢你venky...但我仍然无法看到默认消息
    • 我的意思是通过 - attachment.put("message", "Messages");我无法在发布对话框上看到此消息..它是一个没有消息的空白框...但允许用户输入..我想显示消息并希望允许用户输入在
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-05
    • 1970-01-01
    • 2012-12-30
    • 2021-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多