[英]Javascript facebook sdk login local
我已經在sdk中獲得了這個Facebook登錄名,它在我的服務器上可以正常工作,但是當用戶在線時,我需要在本地路徑(file:// path)中使用它,但是它不起作用,我單擊按鈕沒有任何效果這是代碼
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<meta name="viewport" content="width=320, initial-scale=0.7, user-scalable=no">
<script src="JS/jquery-1.11.1.js.js"></script>
<link rel="stylesheet" type="text/css" href="../css/login.css">
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'MYAPPID', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function(response)
{
if (response.status === 'connected')
{
window.location.replace("gestaccount.html");
}
else
{
}
});
};
function Login()
{
FB.login(function(response) {
if (response.authResponse)
{
} else
{
window.location.replace("errorconn.html");
}
},{scope: 'email,user_photos,publish_actions'});
}
// Load the SDK asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
</head>
<body style=" background: #2c3338;
color: #606468;
margin: 0;">
<div id="navigation">
<table width="100%">
<tr valign="bottom">
<td valign="middle" width="25%" align="center">
<a href="eventi.php"><img src="IMG/icon/prvs.png" class="icons3"/></a>
</td>
<td valign="bottom" width="50%" align="center">
<img src="IMG/LOGO-WHITE.png" class="logonbar" alt="DONUT"/>
</td>
<td width="25%" align="center" valign="middle">
</td>
</tr>
</table>
</div>
<div id="fb-root"></div>
<br>
<div class="containerlogin">
<br><br><br><br><br>
<div id="login" style="display: block; margin:0 auto;" >
<img src="../IMG/LOGIN.png" class="iconlogin" alt="" style="display: block; margin: 0 auto;"/>
<p> <button type="submit" name="fb" onClick="Login()" class="button"> </button>
<p style="margin-left:25px;">Loggati e avrai la possibilità di tenere controllati
tutti le tue prenotazioni tra prevendite e tavoli.
Inoltre se sei PR contattaci per avere accesso a tutte
le funzionalità riservate. </p>
</div> <!-- end login -->
</div>
<br>
<br>
</div>
</div>
</body>
</html>
謝謝你的答案。
它僅適用於http或https協議,不適用於file://
Facebook不再支持從本地文件發出的JS SDK調用,該腳本必須在具有http://或https:// URI的文件上運行。
如果要在本地測試,請嘗試在localhost
上運行
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.