为什么我会收到不同的keyhashes用于注册的Facebook应用程序? [英] Why do I get different keyhashes for registering facebook app?

查看:294
本文介绍了为什么我会收到不同的keyhashes用于注册的Facebook应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经试过

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

和我得到一个keyhash 1knQ67Fx4PUOYXggSe + mnzqaTL8 =

And I get a keyhash 1knQ67Fx4PUOYXggSe+mnzqaTL8=.

不过谷歌自己的文档建议一个替代太

try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.facebook.samples.hellofacebook", 
            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) {
}

但这个收益率 UR02fNgzyMOjpWCxUnjGZ4ctF6Y = 。我有双重验证,我得到这两个值始终与相应的方法。

But this yields UR02fNgzyMOjpWCxUnjGZ4ctF6Y=. I have doubly verified that and I get these two values consistently with the respective approaches.

为什么不同?而且我要注册在哪个developers.facebook.com?的文档不是很清楚它似乎。

Why are they different? And which one should I register at developers.facebook.com? The documentation is not very clear it seems.

编辑:

由于Offbeatmammal说我可以在Facebook的网站上注册多个密钥。所以这是好的。但是,我也应该指定应用程序清单文件中的keyhash。 那么另外问:哪一个,我应该在应用程序的使用呢?当然,我可以尝试,但答案将受到欢迎也是如此。

As Offbeatmammal says I can register multiple keys at facebook site. So that's ok. But I should also specify the keyhash in application manifest file. So additionally asking: which one should I use there in the application? I can of course try it but an answer would be welcome as well.

推荐答案

您将基本需要为你的应用程序至少有2关键哈希值。这是假设,你的工作只是一台计算机上。有关更多的电脑,你将需要生成和开发者控制台添加一个关键散列到你的应用程序的设置。

You will essentially need at least 2 Key Hashes for your application. This is assuming, you are working on just one computer. For additional computer, you will need to generate and add one more Key Hash to your App's settings in the Developer Console.

说明:

当您测试您的应用程序时,Eclipse(与ADT / SDK一起)会一直使用 debug.keystore 作为推动的应用到该设备或仿真器。当您发布的应用程序,您可以使用您生成您的应用程序(发布到谷歌播放)密钥库。

While you are testing your application, eclipse (in conjunction with the ADT / SDK) will always use the debug.keystore for pushing the app to the device or the emulator. When you publish the app, you use the keystore that you generate for your app (for publishing to Google Play).

Facebook的要求主要为哈希既debug.keystore,以及你自己的密钥库。

Facebook requires the Key Hashes for both the debug.keystore as well as your own keystore.

要解决您的问题,您使用两种不同的方法得到不同的密钥哈希值,是我所面对的时候,我开始使用Facebook的Andr​​oid SDK。为了避免这一点,我找到了一个解决方案,始终工作,并始终是precise。您可以按照这些答案的步骤(他们几乎是一样的),你将有你的密钥散列在任何时间工作:

To address your concern that you get different Key Hashes using 2 different methods, is something I have faced when I started using the Facebook Android SDK. To circumvent that, I found a solution that always works and is always precise. You can follow the steps in these answers (they are almost the same) and you will have your Key Hash working in no time:

  1. <一个href="http://stackoverflow.com/a/13283088/450534">http://stackoverflow.com/a/13283088/450534
  2. <一个href="http://stackoverflow.com/a/13343529/450534">http://stackoverflow.com/a/13343529/450534
  3. http://stackoverflow.com/a/10516629/450534 (该解决方案是在这一个意见)
  1. http://stackoverflow.com/a/13283088/450534
  2. http://stackoverflow.com/a/13343529/450534
  3. http://stackoverflow.com/a/10516629/450534 (The solution is in the comments in this one)

所以,总结一下:

  1. 尝试使用上面提供的链接中的步骤,让Facebook的SDK告诉你正确的密钥散列。
  2. 至于哪个键哈希将用于:你不会有决定。既然你已经添加两个关键散列到您的开发者控制台,Facebook将自动使用恰当的。
  3. 在我不知道需要的密钥散列添加到清单文件。它或许可能是实的SDK v3的的要求。在这种情况下,在测试时,请使用 debug.keystore ,当你准备发布的应用程序,切换到所创建的密钥散列使用您的发布密钥库
  4. 的密钥散列创建
  1. Try using the steps from the links provided above to let the Facebook SDK tell you the correct Key Hash.
  2. And as for which Key Hash is to be used: You won't have to decide that. Since you will have added both the Key Hashes to your Developer Console, Facebook will use the appropriate one automatically.
  3. I am not aware of needing to add the Key Hash to the Manifest file. It perhaps may be a requirement of the Facebook SDK v3. In such a case, while testing, use the Key Hash created with the debug.keystore and when you are ready to release the App, change to the Key Hash created using your release keystore.

希望这会解决你的问题。

Hope this addresses your question.

修改

由于Offbeatmammal正如已经指出的那样,你可以添加多个关键散列到你的开发者控制台。因此,存储和使用多个密钥哈希是你将不必担心。

As Offbeatmammal as already pointed out, you can add multiple Key Hashes to your Developer Console. So storing and using multiple Key Hashes is something you won't have to worry about.

这篇关于为什么我会收到不同的keyhashes用于注册的Facebook应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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