android facebook集成无效密钥哈希 [英] android facebook integration invalid key hash

查看:237
本文介绍了android facebook集成无效密钥哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我的一个应用程序,我需要获取fb的数据...我在做...

hello all in one of my app I need to get data of fb... I am doing that..

我已经创建了应用程序ID 它登录成功,但注销后我登录然后它给我

I have created app ID it log in successfully but after log out i Log In then it gives me

我在做什么错?请建议我使用 Facebook sdk ...我已经在我的手机中安装了Facebook ...这个运行良好的模拟器没有内置的Facebook应用程序安装

What is wrong I am doing? Please suggest I am using Facebook sdk... I have installed Facebook in my phone... this running good in emulator that does not have inbuilt Facebook application installed

这是我的代码

 if (FB_APP_ID == null) {
            Builder alertBuilder = new Builder(this);
            alertBuilder.setTitle("Warning");
            alertBuilder.setMessage("A Facebook Applicaton ID must be " +
                    "specified before running this example: see App.java");
            alertBuilder.create().show();
        }

        // Initialize the dispatcher
        Dispatcher dispatcher = new Dispatcher(this);
        dispatcher.addHandler("login", LoginHandler.class);
        dispatcher.addHandler("stream", StreamHandler.class);
        dispatcher.addHandler("logout", LogoutHandler.class);

        // If a session already exists, render the stream page
        // immediately. Otherwise, render the login page.
        Session session = Session.restore(this);
        if (session != null) {
            dispatcher.runHandler("stream");
        } else {
            dispatcher.runHandler("login");
        }


推荐答案

生成哈希键是错误的。您可以使用两个步骤获取散列键。一个是通过命令提示符。另一个是通过编码。 Hash键通过命令提示符工作在第一时间。我不知道原因我也有同样的问题。所以我尝试通过程序化。

The generate hash key is wrong. You may get the hash key using two steps. One is through command prompt. Another one is through coding. Hash key through command prompt working on first time only. I don't know the reason. I have also got the same problem. So i tried it through programatically.

按照以下步骤:

将以下代码粘贴到 oncreate()

try {
    PackageInfo info = getPackageManager().getPackageInfo(
                "com.example.packagename", 
                PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
    }
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

在上面的代码中修改com.example.packagename和您的软件包名称(您可以在Android Manifest文件中找到您的软件包名称)。

Modify "com.example.packagename" with your package name in the above coding without fail(You may found your package name in Android Manifest file).

运行您的应用程序。转到粘贴上述代码的活动。在logcat中搜索KeyHash。你可能会发现一个键哈希。复制密钥哈希并转到Facebook应用程序信息中心页面。转到设置并输入详细信息,如下图所示。

Run your application. Go to the activity where you pasted the above code. In the logcat search for "KeyHash". You may found a key hash. Copy the key hash and go to Facebook application dashboard page. Go to settings and enter the details like in the bellow image.

完成上述步骤后,请重新启动该应用程序,您可以登录Facebook。
有关密钥哈希的更多详细信息,请查看链接

Once you finished the above step. Relaunch the app again you may now log into the facebook. For more details about key hash check the link

如果在设置页面中添加错误的信息意味着会给出一些错误。所以在那里使用正确的信息。而且如果公众(除了你以外)需要使用你的申请意味着你需要启用权限(在设置旁边的状态和评估中更改是)

If you add a wrong information in the settings page means it will give some error. so use the correct information there. And also if public(other than you) need to use your application means you need to enable the permission(change "yes" in the "Status & Review" next to setting).

这篇关于android facebook集成无效密钥哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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