如何利用最新的Facebook SDK为Android发布在Facebook图片和网址 [英] how to publish image and url on facebook using latest facebook SDK for Android

查看:160
本文介绍了如何利用最新的Facebook SDK为Android发布在Facebook图片和网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Facebook对话框,显示在此链接的最后一个影像。但我无法看到默认的消息,也没能看到图像。我写这篇code与此帮助<一个href="http://stackoverflow.com/questions/8893331/how-to-show-the-publish-dialog-box-when-using-facebook-integration-with-android">link详细信息。

I want to create a facebook dialog as shown in the last image of this link. But I am not able to see the default message and also not able to see the image. I wrote this code with help of this link details.

我缺少的东西。

下面是相同的code快照

Here is the code snapshot for the same

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


    }

我缺少的是什么? 请帮助我坚持......

what I am missing... Please help I am stuck...

拉​​吉

推荐答案

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

Try this Snippet for Posting Image along with additional Details :

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

这篇关于如何利用最新的Facebook SDK为Android发布在Facebook图片和网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆