我正在尝试使用 javascript 实现 facebook accountkit。我遵循了 https://developers.facebook.com/docs/accountkit/web/integrating 上的文档。
AccountKit 登录表单
Enter country code (e.g. +1):
<input type="text" id="country_code" />
Enter phone number without spaces (e.g. 444555666):
<input type="text" id="phone_num"/>
<button onclick="phone_btn_onclick();">Login via SMS</button>
Enter email address
<input type="text" id="email"/>
<button onclick="email_btn_onclick();">Login via Email</button>
以下是我的应用程序上的 javascript 代码
<script src="https://sdk.accountkit.com/en_US/sdk.js"></script>
<script>
// initialize Account Kit with CSRF protection
AccountKit_OnInteractive = function(){
AccountKit.init(
{
appId:'facebook_app_id',
state:"csrf",
version:"accountkit_version"
}
);
};
// login callback
function loginCallback(response) {
console.log(response);
if (response.status === "PARTIALLY_AUTHENTICATED") {
document.getElementById("code").value = response.code;
document.getElementById("csrf_nonce").value = response.state;
document.getElementById("my_form").submit();
}
else if (response.status === "NOT_AUTHENTICATED") {
// handle authentication failure
}
else if (response.status === "BAD_PARAMS") {
// handle bad parameters
}
}
// phone form submission handler
function phone_btn_onclick() {
var country_code = document.getElementById("country_code").value;
var ph_num = document.getElementById("phone_num").value;
AccountKit.login('PHONE',
{countryCode: country_code, phoneNumber: ph_num}, // will use default values if this is not specified
loginCallback);
}
// email form submission handler
function email_btn_onclick() {
var email_address = document.getElementById("email").value;
AccountKit.login('EMAIL', {emailAddress: email_address}, loginCallback);
}
</script>
为
appId
、 state
和 version
设置所需的值后。我尝试填写表格,但我重定向到帐户工具包页面说we are sorry, something went wrong, try again
任何实现方面的帮助将不胜感激。提前致谢
最佳答案
这个问题已经解决。在 facebook 开发人员网站上的帐户工具包页面上,我将 server url
上的 web login settings
指向域的所有出现,即 http://domain.com , http://www.domain.com 包括 https
如果可用。这解决了问题。谢谢大家。
关于javascript - Facebook Accountkit JAVASCRIPT 实现,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36676957/