在Corona SDK中,facebook.login()无法正常工作。

我已经按照所有步骤为用 Corona 构建的游戏创建了一个 Android 密钥散列值,并为用户登录 Facebook 帐户创建了一个按钮。但是当用户点击按钮时,没有错误消息和响应,只有打印输出。

我漏掉了什么?请帮忙。

  • 我使用 OPENSSL 创建了密钥哈希值
  • 输入 Facebook 开发者的应用程序 ID
  • 将密钥哈希值输入 Facebook 开发者
  • 启用“单点登录”和“深度链接”
  • 在 Facebook 开发人员中输入类名称“com.ansca.corona.CoronaActivity”
  • 在 build.settings 中包括“android.permission.INTERNET”
local facebook = require ("facebook")
local fbAppID = "49911xxxxxx"

local function onClick( event )
  if ( "ended" == event.phase ) then
    print( "Button was pressed and released" )
    facebook.login( fbAppID, facebookListener, { "publish_actions, email" } )
  end
end

-- Facebook Button
FacebookButton = widget.newButton
  {
    defaultFile = "images/fb.png" ,
    width = 240,
    height = 120,
    onEvent = onClick,
  }
FacebookButton.x = display.contentWidth / 2
FacebookButton.y = display.contentHeight / 2
点赞
用户2639160
用户2639160

我不确定你是否已经解决了这个问题,但我也遇到了这个问题。当你尝试通过 Facebook 登录时,会出现错误提示:

“无效的密钥散列码,与 xxxxxxxxxxxxx 不匹配,请在(此处输入您的网站)中配置。”我一遍又一遍地复制散列码并检查它……

直到最后终于意识到,小写字母“L”实际上是一个大写字母“I” o.0 它解决了!祝你好运!

此外,这里有一个小代码片段,对我有些帮助

local function facebookListener(event)
    if (event.type == "session") then
        if (event.phase == "login") then
            sessionToken = event.token
            local response = event.response
            native.showAlert("My Response", response)
             --facebook.request("me", "GET", {fields = "email"})
        elseif (event.type == "request") then
            local response = event.response
            native.showAlert("My Response", response)
        end
    end
end
facebook.login( appId, facebookListener, {"publish_actions, email, public_profile"})
2014-06-27 20:08:39