繁体   English   中英

从Facebook SDK for Android向Facebook提要对话框添加内容

[英]Adding content to Facebook feed dialog from Facebook SDK for Android

在我的Android应用程序中,我希望用户在他们的墙上“共享”我的应用程序,所以我希望他们在他们的墙上发布预定义的内容状态。

如何自定义墙状态? (我想添加我的应用程序图标和一些耀斑文本)。

下载Facebook SDK并将其导入您的项目中。 然后使用以下代码进行授权:

    public void sendtoFacebook(){
        facebookClient = new Facebook("<Your_APP_ID");
        facebookClient.authorize(<Current_class>.this, new AuthorizeListener());
    }

现在你必须添加以下方法:

class AuthorizeListener implements DialogListener {
    public void onComplete(Bundle values) {
        Bundle parameters = new Bundle();
            parameters.putString("message", "<Message_you_want_to_send>");// the message to post to the wall
            facebookClient.dialog(<Current_class>.this, "stream.publish", parameters, this);// "stream.publish" is an API call
    }
    @Override
    public void onFacebookError(FacebookError e) {
    }
    @Override
    public void onError(DialogError e) {
    }
    @Override
    public void onCancel() {
    }
}

您的应用程序名称和图标将自动添加:)

在学习Facebook API之后,我遇到了这个页面

所以现在我知道了bundle参数的所有选项。 谢谢大家的帮助!

这就是我使用Facebook SDK通过Facebook对话框设置内容的方法

Bundle parameters = new Bundle();
        parameters.putString("app_id", "xxxxxxx");
        parameters.putString("link", "https://play.google.com/store/apps/details?id=myappistasty");
        parameters.putString("name", "This is the name of the link set in app.");
        parameters.putString("caption", "This is Text that is specified in bt the aoo");
        parameters.putString("picture", "www.urltoimage.com);
facebook.dialog(MainActivity.this, "feed", parameters, new DialogListener() {
etc...

http://developers.facebook.com/docs/reference/dialogs/feed/这是向我解释所有内容的链接,虽然没有一个在java中,但表格给你一个好主意。

您也可以在没有SDK的情况下通过共享URL进行操作:

public void shareOnFacebook(View v) {

    Uri uri = Uri.parse("http://m.facebook.com/sharer.php?u=http://yourdomain/page.html&t=YourMessage");
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    startActivity(intent);
}

您只需将内容页面/ html放在服务器上的某个位置,在您提供给共享者的URL下。

如果您希望共享消息中显示某个图像,请将其放在您共享的服务器上的html页面的元标记中:

<link rel="image_src" type="image/jpeg" href="http://yourdomain.com/promo/image.png" /> 

查看带有链接图像的此类促销页面示例: http//www.modelme.co.uk/promo/amandaharrington

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM