Android的Facebook的API密钥哈希不匹配任何商店关键散列 [英] android facebook API Key hash not match any store key hashes

查看:551
本文介绍了Android的Facebook的API密钥哈希不匹配任何商店关键散列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是之前回答的问题,但似乎没有人工作,我花一个星期的int值。

I know that's a question answered before, but no one seems to work and i spend a week on int.

我试图从关键工具让我的密钥散列并把他们在Facebook上的应用程序的关键哈希,发布和调试。没有人的工作。
(404)主要散XXXXXXXXXXXX不匹配任何storeed键哈希值
这是罕见的,我的钥匙是不同的。

I tried to get my Key Hash from key tool and put them on Facebook app Key hashes, release and debug. No one worked. "(404) Key hash xxxxxxxxxxxx does not match any storeed key hashes" That's rare, my keys are different.

所以我尝试:

PackageInfo info = getPackageManager().getPackageInfo(
                                    "com.pakage.example", 
                                    PackageManager.GET_SIGNATURES);
                            for (Signature signature : info.signatures) {
                                MessageDigest md = MessageDigest.getInstance("SHA");
                                md.update(signature.toByteArray());
                                String result = Base64.encodeToString(md.digest(), Base64.DEFAULT);
                                Toast.makeText(MainActivity.this , result + result.toUpperCase(), Toast.LENGTH_LONG).show();
                            }    

这回我同样的密钥已被Facebook(XXXXXXXXXXXX)的要求,所以我说他们的Facebook应用程序,但Facebook回报我。(404)主要散XXXXXXXXXXXX不匹配任何storeed键哈希值。

That return me the same Key Has request by Facebook (xxxxxxxxxxxx), so i added them to Facebook App, but Facebook return me "(404) Key hash xxxxxxxxxxxx does not match any storeed key hashes".

当我从设备中删除Facebook应用,我是通过avaliebe到WebDialog共享状态。

When i removed Facebook App from my device, i was avaliebe to share status via WebDialog.

我的最后code似乎是:

My final code seems to:

if (FacebookDialog.canPresentShareDialog(parent, FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) 
    {
        publishFacebookDialog(points);  //FacebookDialog
    } 
    else 
    {
        Session session = Session.getActiveSession();
        if (session != null && session.isOpened()) {
           publishFeedDialog(points);  //WebDialog
        }
        else
        {
            Intent intent = new Intent(parent, LoginUsingCustomFragmentActivity.class); //From FacebookSDK demo
            parent.startActivityForResult(intent, 666);        
        }
    }

PublishFacebookDialog功能:

PublishFacebookDialog function:

private void publishFacebookDialog(String puntuacion) {
    FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(parent)
    .setLink("bla")
    .setCaption("bla")
    .setName("bla")
    .build();
    uiHelper.trackPendingDialogCall(shareDialog.present());
}

PublishFeedDialog功能:

PublishFeedDialog function:

private void publishFeedDialog(String puntuacion) {
    Bundle params = new Bundle();
    params.putString("name", "bla");
    params.putString("caption", "bla");
    params.putString("link", "bla");

    WebDialog feedDialog = ( new WebDialog.FeedDialogBuilder(parent,Session.getActiveSession(),params))
        .setOnCompleteListener(new OnCompleteListener() {

            @Override
            public void onComplete(Bundle values, FacebookException error) {
                if (error == null) {
                    final String postId = values.getString("post_id");
                    if (postId != null) {

                    } else {

                    }
                } else if (error instanceof FacebookOperationCanceledException) {
                    // User clicked the "x" button

                } else {
                    // Generic, ex: network error

                }
            }

        })
        .build();
    feedDialog.show();
}

该LoginUsingCustomFragmentActivity类是相同的FacebookSDK

The LoginUsingCustomFragmentActivity class is the same that FacebookSDK

试过:


  • 从Facebook上删除应用程序,然后重新添加。

  • 替换像符号/ ​​_ +等,像其他回答的帖子。

  • 使用所报告的相同的密钥哈希(404)主要散XXXXXXXXXXXX不......在Facebook上的应用程序。

任何想法?

感谢很多东西。

推荐答案

我面临同样的问题,我通过OpenSSL的生成散列code是错误的,然后我用这个功能,它帮助。希望它可以帮助你太。

I was facing the same problem, the hash code that i generated through openssl was wrong i then used this function and it help. Hope it help you all too.

private void printKeyHash() {
    // Add code to print out the key hash
    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) {
        Log.e("KeyHash:", e.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.e("KeyHash:", e.toString());
    }
}

使用哈希code打印在日志和享受。快乐编码:)

Use the hash code that is printed in logs and enjoy. Happy Coding :)

这篇关于Android的Facebook的API密钥哈希不匹配任何商店关键散列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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