2014-04-24 38 views
0

我已經拋出了所有步驟,爲我的遊戲在corona中構建android創建了一個鍵哈希。我爲用戶登錄Facebook帳戶創建了一個按鈕。但是當用戶觸摸按鈕時沒有任何錯誤消息和響應。只有打印輸出。facebook.login()在Corona SDK中不工作

我錯過了什麼?請幫忙。

  • 我使用OpenSSL創建密鑰哈希
  • 從Facebook開發人員輸入應用ID
  • 回車鍵哈希Facebook的開發者
  • 啓用「單點登錄」和「深層鏈接」
  • 進入類別名稱「com.ansca.corona.CoronaActivity」on Facebook開發人員
  • 在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 

回答

0

我不確定,如果你有固定的這個問題,但我也一直有這個問題。當你去通過Facebook登錄,它給你一個錯誤說:

「無效密鑰哈希碼,它不匹配xxxxxxxxxxxxx配置它(你的網站在這裏)」我複製哈希碼並檢查它,再次...

只有最後認識到小寫字母「L」實際上是一個大寫的「我」o.0它修復了它!祝你好運! 此外,這裏是一個小代碼snippit,幫助我一點點

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