次のコードはFirefoxまたはIEでは機能しないようですが、Chromeでは正常に動作します。誰かが私が間違っていることについて何らかの洞察を持っているかもしれないことを願っています。FacebookキャンバスでUnityゲームを実行するために使用されます。
<script type='text/javascript'>
var appID = 'xxxxxxxxxxxxxxxxxxx';
var connected = false;
var loggedin = false;
var purchaseResult = "Failed";
var inviteResult = "Failed";
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : appID, // App ID from the App Dashboard
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
oauth : true, // enable OAuth 2.0
frictionlessRequests : true,
xfbml : false // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
//Get the current login status.
document.getElementById("text").innerText = "Getting login status";
console.log("Getting login status");
FB.getLoginStatus(function(response) {
console.log("got response");
var user_box = document.getElementById("login");
//document.getElementById("text").innerText = "Got response: " + response.status;
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
console.log("Getting login status returned user id: " + uid);
var accessToken = response.authResponse.accessToken;
//user_box.style.visibility = 'hidden';
loggedin = true;
//document.write("Connected to facebook");
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
user_box.style.display = 'block';
FB.Event.subscribe('auth.login', function(response) {
// Let unity know the user has logged in
GetCurrentUser();
user_box.style.display = 'none';
});
} else {
// the user isn't logged in to Facebook.
FB.Event.subscribe('auth.login', function(response) {
// Let unity know the user has logged in
GetCurrentUser();
user_box.style.display = 'none';
});
user_box.style.display = 'block';
}
if (loggedin) {
GetCurrentUser();
}
}, true);
};
何が起こっているかを確認するためにそこにログメッセージがありますが、「ログインステータスの取得」の後にメッセージを受け取るのはChromeだけです。
ありがとう、アンドリュー。