Facebook发布key_hash

时间:2013-10-21 13:03:23

标签: android facebook facebook-android-sdk

我有生成密钥哈希的问题。 我做了2把钥匙:

C:\openssl\bin>"C:\Program Files\Java\jre7\bin\keytool.exe" -exportcert -alias forumurology -keystore uroweb7228.keystore | openssl sha1 -binary | openssl base64
Enter keystore password:  *******
c/6e5fY8Rg3Gshn1TKucia***/A=

C:\openssl\bin>"C:\Program Files\Java\jre7\bin\keytool.exe" -exportcert -alias a
ndroiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
Enter keystore password:  android
3L0oeMh7uk9YWE0sYavUuT***yU=

然后将其保存到我的Facebook应用程序设置。 当我运行发布.apk时,我有错误:

10-21 16:48:11.583: W/fb4a(:<default>):BlueServiceQueue(20097): Exception during service
10-21 16:48:11.583: W/fb4a(:<default>):BlueServiceQueue(20097): com.facebook.http.protocol.ApiException: Key hash ypC1--aybTSQXdzXGLtM-_nXydI does not match any stored key hashes.
10-21 16:48:11.583: W/fb4a(:<default>):BlueServiceQueue(20097):     at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:83)

1 个答案:

答案 0 :(得分:3)

这是因为设备正在创建一个不在您的应用设置中的新密钥哈希。所以你必须相应地更新keyhash ..在onCreate()

中使用它
try {
            PackageInfo info = getPackageManager().getPackageInfo("YOUR_PACKAGE_NAME", 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) {

        }