我想创建一个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());
}
我错过了什么?
答案 0 :(得分: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());
}