【发布时间】:2013-03-05 04:44:54
【问题描述】:
在拼命尝试将 facebook 登录系统集成到我的网站 3 天之后,我得出的结论是我惨败。我只是用 JavaScript SDK API 调用创建了一堆乱七八糟的 PHP SDK,结果和预期的一样,没有工作。
我在 Google 和 stackoverflow 上搜索了其他人的问题、教程、解释的答案,但我现在承认自己失败了。
你能给我这个工作的好教程吗?或者你能给我深入了解一下他们的图书馆吗?
希望这不会被关闭。
编辑:这是使用 Facebook 登录系统的推荐方法吗?
编辑 2:
FB.init({
appId : '<?php echo $core->appId; ?>', // App ID from the App Dashboard
channelUrl : '//romeo.no-ip.org/94seconds/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
此代码生成FB.getLoginStatus() called before calling FB.init().
我的页面如下所示:
<!DOCTYPE html>
<html>
<head>
<script src="../node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $core->appId; ?>', // App ID from the App Dashboard
channelUrl : '//romeo.no-ip.org/94seconds/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
};
// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function(d, debug){
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" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
</body>
</html>
编辑 3:没关系,我刚刚意识到我已经花了 3 - 4 个小时打墙,因为我放错了一些代码。我已经失去了错误。 :D 谢谢你们。
【问题讨论】:
-
Can you give me a good tutorial for this job?直接要求人们为您使用 Google。 -
@tradyblix:不。只是询问是否有人遇到过、制作过或学习过。
-
@hakre :你是在温和地建议我不要使用 OAuth2 吗?
-
不,只是它有一些粗糙的边缘。
标签: php javascript facebook oauth-2.0 facebook-oauth