Facebook JS SDK未设置cookie
我正在尝试在我们的web应用程序中实现Facebook身份验证,服务器端处理Facebook cookie。我们使用JavaScript SDK执行登录并设置cookie 然而,不知何故,Facebook SDK似乎没有设置我们的fbsr_APPID cookie(或任何cookie)。这是CoffeeScript代码:Facebook JS SDK未设置cookie,facebook,coffeescript,facebook-javascript-sdk,Facebook,Coffeescript,Facebook Javascript Sdk,我正在尝试在我们的web应用程序中实现Facebook身份验证,服务器端处理Facebook cookie。我们使用JavaScript SDK执行登录并设置cookie 然而,不知何故,Facebook SDK似乎没有设置我们的fbsr_APPID cookie(或任何cookie)。这是CoffeeScript代码: window.fbCallbacks = [] # Create initialization function window.fbAsyncInit = ->
window.fbCallbacks = []
# Create initialization function
window.fbAsyncInit = ->
fbConfig =
appId: '<APPID here>'
channelUrl: '/assets/channel.html'
status: true
cookie: true
xfbml: true
FB.init fbConfig
cb() for cb in window.fbCallbacks
# Set it up
((d)->
id = 'facebook-jssdk'
ref = d.getElementsByTagName('script')[0]
return if d.getElementById id
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)
window.fbCallbacks=[]
#创建初始化函数
window.fbAsyninit=->
fbConfig=
appId:'也无法使其工作
发生了什么事?为什么Facebook没有设置我的应用程序cookie
以下是由上述CoffeeScript生成的JavaScript供参考:
(function() {
window.fbCallbacks = [];
window.fbAsyncInit = function() {
var cb, fbConfig, _i, _len, _ref, _results;
fbConfig = {
appId: '<appid>',
channelUrl: '/assets/channel.html',
status: true,
cookie: true,
xfbml: true
};
FB.init(fbConfig);
_ref = window.fbCallbacks;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
cb = _ref[_i];
_results.push(cb());
}
return _results;
};
(function(d) {
var id, js, ref;
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";
return ref.parentNode.insertBefore(js, ref);
})(document);
}).call(this);
(函数(){
window.fbCallbacks=[];
window.fbAsyninit=函数(){
var cb、fbConfig、_i、_len、_ref、_results;
fbConfig={
appId:“”,
channelUrl:“/assets/channel.html”,
状态:正确,
曲奇:是的,
xfbml:对
};
FB.init(fbConfig);
_ref=window.fb回调;
_结果=[];
对于(_i=0,_len=_ref.length;_i<_len;_i++){
cb=_ref[_i];
_结果:push(cb());
}
返回结果;
};
(职能(d){
变量id,js,ref;
id='FacebookJSSDK';
ref=d.getElementsByTagName('script')[0];
if(d.getElementById(id)){
返回;
}
js=d.createElement('script');
js.id=id;
js.async=true;
js.src=“//connect.facebook.net/en_US/all.js”;
返回ref.parentNode.insertBefore(js,ref);
})(文件);
}).打电话(这个);
看来我误解了SDK。登录按钮小部件实际上并没有在本地设置cookie;它完全通过Facebook和JavaScript管理身份验证和访问,因此不允许您访问服务器上的身份验证令牌
使用JSSDK的FB.login()函数设置了cookie
(function() {
window.fbCallbacks = [];
window.fbAsyncInit = function() {
var cb, fbConfig, _i, _len, _ref, _results;
fbConfig = {
appId: '<appid>',
channelUrl: '/assets/channel.html',
status: true,
cookie: true,
xfbml: true
};
FB.init(fbConfig);
_ref = window.fbCallbacks;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
cb = _ref[_i];
_results.push(cb());
}
return _results;
};
(function(d) {
var id, js, ref;
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";
return ref.parentNode.insertBefore(js, ref);
})(document);
}).call(this);