Phonegap构建 - Facebook连接插件 - 无效的android_key参数错误 [英] Phonegap build - Facebook connect plugin - Invalid android_key parameter error

查看:197
本文介绍了Phonegap构建 - Facebook连接插件 - 无效的android_key参数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行示例代码(如下所示),通过phonegap构建来生成一个Android apk。



https://github.com/phonegap-build/FacebookConnect/blob/master/example/Simple/index.html



当我尝试通过android设备上的应用程序(安装了Facebook应用程序)登录到Facebook时,我收到此错误:


无效的android_key参数J4INwYsuTyQ_LJc1d3WZ2HReg7M与任何允许的android键不匹配。在 http://developers.facebook.com/apps/ 的应用程序ID中配置应用程序键哈希值'


我将这个密钥复制到我应用程序的Android设置的关键哈希部分,但是当我尝试使用该应用程序登录。



如何让该应用程序成功登录Facebook?



以下是我所做的一些事情: p>


  • 在我的Facebook应用的设置中:




    • 将'Package name'设置为我的phonegap config.xml中找到的'widget id'。

    • 将'Class name'设置为附加了'.ProjectActivity'的包名称。 / li>
    • 启用单一登录并禁用深度链接。

    • 让应用向公众开放(通过th e'状态和审查部分。


  • 在我的phonegap config.xml(在/ www目录中的phonegap项目):




    • 输入APP_ID作为我的Facebook应用程序信息中心中找到的ID

    • 输入APP_NAME在我的Facebook应用设置中找到的命名空间


  • 在我的手机构建应用设置中:





解决方案

我成功制作了一个应用程序,可以使用phonegap-facebook-plugin登录到Facebook,并在本地建立我的cordova / phonegap项目。



我创建了一个新的cordova项目,并为此项目添加了Android平台,遵循以下说明: http://docs.phonegap.com/en/3.4.0/guide_overview_index.md.html#Overview



在这样做的时候,我发现我没有使用旧的cordova版本(3.1),而是没有安装cordova命令行界面。可能还有其他问题,我做了我的第一个项目。



然后,我添加了这里找到的phonegap-facebook-plugin: https://github.com/phonegap/phonegap-facebook-plugin 使用此命令(从我的项目位置):

  cordova插件添加https://github.com/phonegap/phonegap-facebook-plugin.git  - 变量APP_ID =xxxxxxxxxxxxx - 变量APP_NAME =xxxxxxxx

(用我的Facebook应用程序ID和APP_NAME值替换APP_ID值我的应用程序的命名空间)。



然后我用index.html替换了在phonegap-facebook-plugin github页面上找到的示例索引文件+ / blob / master / example /简单/ index.html(用我的应用程序ID替换app_id值)。



然后,我将应用程序直接运行到我的Android设备:

  cordova运行android 

在这个应用程序中,我可以使用示例提供的界面登录,发布到我自己或朋友的墙壁等。使用这个新项目(更新的cordova版本)我可能使用phonegap构建,但我还没有尝试过。



感谢Dato的Mohammad Nurdin建议使用这个插件。


I'm running example code (found below) through phonegap build to produce an android apk.

https://github.com/phonegap-build/FacebookConnect/blob/master/example/Simple/index.html

When I try to log into facebook through the app on an android device (with the facebook app installed), I get this error:

Invalid android_key parameter J4INwYsuTyQ_LJc1d3WZ2HReg7M does not match any allowed android key. Configure your app key hashes at http://developers.facebook.com/apps/'app id'

I have copy-pasted this key into the key hashes section of my app's android settings but it still throws the same error when I try to log in using the app.

How can I get this app to log into facebook successfully?

OR: What is another way to enable an android app to log into facebook using phonegap?

Here are some things I have done:

  • In my facebook app's settings:

    • Set 'Package name' to the 'widget id' found in my phonegap config.xml.
    • Set 'Class name' to the Package name with '.ProjectActivity' appended to it.
    • Enabled 'Single Sign on' and disabled 'Deep linking'.
    • Made the app open to the public (through the 'Status & Review' section.
  • In my phonegap config.xml (found in the /www directory in phonegap project):

    • Entered APP_ID as the ID found in my facebook app dashboard
    • Entered APP_NAME as the 'Namespace' found in my facebook app settings
  • In my phonegap build app settings:

解决方案

I successfully made an app which can log into facebook by using the phonegap-facebook-plugin and by building my cordova/phonegap project locally.

I made a new cordova project and added the android platform for this project, following the instructions here: http://docs.phonegap.com/en/3.4.0/guide_overview_index.md.html#Overview

In doing this I discovered I had made my previous project using an older cordova version (3.1) un-intentionally and that I hadn't installed the cordova command line interface. There may have been other issues with the way I made my first project.

I then added the phonegap-facebook-plugin found here: https://github.com/phonegap/phonegap-facebook-plugin using this command (from my project location):

    cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable       APP_ID="xxxxxxxxxxxxx" --variable APP_NAME="xxxxxxxx"

(replacing APP_ID value with my facebook app id and APP_NAME value with my app's namespace).

I then replaced my index.html with the example index file found at the phonegap-facebook-plugin github page + /blob/master/example/Simple/index.html (replacing the app_id value with my app id).

I then ran the app straight to my android device using:

    cordova run android

In this app, I'm able to use the interface provided by the example to login, post to my own or friends' walls etc. Using this new project (with updated cordova version) I may be able to use phonegap build but I haven't tried yet.

Thanks to Dato' Mohammad Nurdin for the suggestion to use this plugin.

这篇关于Phonegap构建 - Facebook连接插件 - 无效的android_key参数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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