Facebook OAuth2.0实现 [英] Facebook OAuth2.0 Implementation
本文介绍了Facebook OAuth2.0实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
window.addEvent('domready',function ){
FB.init(<%= ConfigurationManager.AppSettings [ApiKey]。ToString()%>,
/xd_receiver.htm,
{ifUserConnected :update_user_is_connected,
ifUserNotConnected:update_user_is_not_connected,
doNotUseCachedConnectState:true});
});
解决方案
这个问题真的没有解释太多,但猜测一点点,这样做应该做(我不熟悉旧的api,所以我不知道你是否必须传递任何参数update_user_is_connected / not_connected,相应地修改):
window.fbAsyncInit = function(){
FB.init({
appId:'<%= ConfigurationManager.AppSettings [ ApiKey]。ToString()%>',
status:true,//检查登录状态
cookie:true,//启用Cookie以允许服务器访问会话
xfbml :true,// parse XFBML
channelUrl:'http://www.yourdomain.com/channel.html',//自定义渠道网址
oauth:true //启用OAuth 2.0
});
FB.getLoginStatus(function(response){
if(response.authResponse)update_user_is_connected();
else update_user_is_not_connected();
});
//一旦用户登录到Facebook(通过您的站点)
FB.Event.subscribe('auth.login',function(response){
update_user_is_connected();
});
};
您可以阅读更多信息:
http://developers.facebook.com/docs/reference/javascript/FB。 getLoginStatus /
I am new to Facebook implementation . Please help me to implement this code through new all.js using OAuth2.0
window.addEvent('domready', function(){
FB.init("<%= ConfigurationManager.AppSettings["ApiKey"].ToString() %>",
"/xd_receiver.htm",
{"ifUserConnected": update_user_is_connected,
"ifUserNotConnected": update_user_is_not_connected,
"doNotUseCachedConnectState":"true"});
});
解决方案
The question doesn't really explain much, but guessing a little bit, something like this should do (I'm not familiar with the old api, so I don't know whether you have to pass any arguments to update_user_is_connected/not_connected, modify that accordingly):
window.fbAsyncInit = function() {
FB.init({
appId : '<%= ConfigurationManager.AppSettings["ApiKey"].ToString() %>',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://www.yourdomain.com/channel.html', // Custom Channel URL
oauth : true //enables OAuth 2.0
});
FB.getLoginStatus(function(response) {
if (response.authResponse) update_user_is_connected();
else update_user_is_not_connected();
});
// This will be triggered as soon as the user logs into Facebook (through your site)
FB.Event.subscribe('auth.login', function(response) {
update_user_is_connected();
});
};
You can read more at:
http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
这篇关于Facebook OAuth2.0实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文