Android的facebook集成无效密钥散列 [英] android facebook integration invalid key hash

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

问题描述

您好所有我的应用程序之一,我需要得到FB的数据...我这样做。

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

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

这是我的code

 如果(FB_APP_ID == NULL){
            构建alertBuilder =新生成器(本);
            alertBuilder.setTitle(警告);
            alertBuilder.setMessage(Facebook的的一个应用ID必须是+
                    运行这个例子之前规定:见App.java);
            alertBuilder.create()显示()。
        }

        //初始化调度
        调度调度=新的调度程序(本);
        dispatcher.addHandler(登录,LoginHandler.class);
        dispatcher.addHandler(流,StreamHandler.class);
        dispatcher.addHandler(注销,LogoutHandler.class);

        //如果会话已经存在,呈现流页面
        // 立即。否则,渲染登录页面。
        会话会话= Session.restore(本);
        如果(会话!= NULL){
            dispatcher.runHandler(流);
        } 其他 {
            dispatcher.runHandler(登录);
        }
 

解决方案

生成散列关键字是错误的。你可能会使用两个步骤的哈希键。一种是通过命令提示符。另一种是通过编码。通过命令提示符哈希键工作仅第一次。我不知道原因。我也得到了同样的问题。所以,我想它通过编程。

按照以下步骤操作:

粘贴的OnCreate以下code()

 尝试{
        PackageInfo信息= getPackageManager()。getPackageInfo(
                com.example.packagename
                PackageManager.GET_SIGNATURES);
        对于(签名签名:info.signatures){
            消息摘要MD = MessageDigest.getInstance(SHA);
            md.update(signature.toByteArray());
            Log.d(KeyHash:Base64.en codeToString(md.digest(),Base64.DEFAULT));
            }
    }赶上(的NameNotFoundException E){

    }赶上(抛出:NoSuchAlgorithmException E){

    }
 

修改com.example.packagename与您包名称​​中没有失败上述编码(您可能会发现在Android清单文件中的包名)。

运行应用程序。转至您粘贴上述code的活性。在logcat中搜索KeyHash。您可能发现了一个关键的哈希值。复制密钥散列并转到Facebook应用程序仪表板页面。进入设置,输入详细信息,如在波纹管的形象。

一旦你完成了上述步骤。再次重新启动应用程序你现在可以登录到Facebook上。 有关密钥散列的详细信息查看链接

如果您在设置中添加一个错误信息页面意味着它会给出一些错误。所以用正确的信息在那里。并且,如果公众(除你之外)需要使用你的应用意味着你需要启用(在状态和放大器;审查变是旁设置)的权限

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

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

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

this is my code

 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");
        }

解决方案

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.

Follow this steps:

Paste the following code in 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) {

    }

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

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.

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天全站免登陆