我如何只使用其Android SDK在Facebook上分享墙内容? [英] How do I simply share content on Facebook wall using its Android SDK?

查看:114
本文介绍了我如何只使用其Android SDK在Facebook上分享墙内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到FB + Android SDK中的许多例子,样品是不够简单(其中有些是去precated)。我简单的目标是用我的Andr​​oid应用程序共享FB上的一些内容。当我开发的iOS应用程序是简单

I cannot find many examples of the FB + Android SDK and the samples are not simple enough(some of them are deprecated). My simple goal is to share some content on FB using my Android app. When I developed the iOS app it was simply

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate facebookLogin];


NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"pikSpeak", @"name",
                               shareURL, @"link",
                               @"pikSpeak for iPhone !", @"caption",
                               @"Record audio at the moment of the image taken using pikSpeak and feel the moment come alive", @"description",
                               @"shared an audible pic using pikSpeak cam", @"message",
                               imageURL,@"picture",
                               nil];

[[appDelegate facebook] requestWithGraphPath:@"feed" andParams:params andHttpMethod:@"POST" andDelegate:self];

这code处理的会话并保存会话信息在应用程序重新启动。

This code handled the sessions and saving the session details over app restarts.

1)如何简单地分享一些东西的Andr​​oid。

1) How to simply share some thing in Android.

2)我看到的Facebook(字符串APP_ID)是德precated。如果是这样,那么什么是它的替代?

2) I saw Facebook(String app_id) is deprecated. If so, then what is its replacement?

P.S。 :使用Facebook 3.0 SDK

P.S. : Using Facebook 3.0 SDK

推荐答案

从的分享到用户的墙使用Facebook的SDK

private void share() {
    Bundle bundle = new Bundle();
    bundle.putString("caption", "Harlem Shake Launcher for Android");
    bundle.putString("description", "Your android can do the Harlem Shake. Download it from google play");
    bundle.putString("link", "https://play.google.com/store/apps/details?id=mobi.shush.harlemlauncher");
    bundle.putString("name", "Harlem Shake Launcher");
    bundle.putString("picture", "http://shush.mobi/bla.png");
    new WebDialog.FeedDialogBuilder(mContext, mySession, bundle).build().show();
}


如果您需要登录(在你的活动,无论你需要登录/股添加此):


If you need to login (add this in you activity wherever you need to login/share):

Session.openActiveSession(this, true, new Session.StatusCallback() {

    @Override
    public void call(Session session, SessionState state, Exception exception) {
        if(session.isOpened()) {
            share();
        }
    }
});

您将需要添加到您的活动:

You will need to add to your activity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch(requestCode) {
    default:
        if(Session.getActiveSession() != null) //I need to check if this null just to sleep peacefully at night
            Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
        break;
    }
}

这篇关于我如何只使用其Android SDK在Facebook上分享墙内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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