作者iii125 (小 i)
看板Ajax
标题[问题]facebook用jQuery
时间Thu Aug 19 17:03:28 2010
最近小弟遇到了几个问题
就是现在再用jQuery写facebook的登入
现在就是用本尊的帐号测试都还没有问题
但是用其他帐号的时候
在登入的状态时
却还是抓不到使用者的session
在未登入的状态下
也无法进入登入页面
请请板上的大大指点迷津
程式码:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Connect JavaScript - jQuery Login Example</title>
</head>
<body>
<h1>Connect JavaScript - jQuery Login Example</h1>
<div id="user-info" style="display: none;"></div>
<script
src="
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<div id="fb-root"></div>
<script src="
http://connect.facebook.net/zh_TW/all.js"></script>
<script>
// initialize the library with the API key
FB.init({ apiKey: 'xxxxxxxxxxxxxxxxxxx' });
// fetch the status on load
FB.getLoginStatus(handleSessionResponse);
check();
function check()
{
FB.getLoginStatus(function(response)
{
if (!response.session)
{
FB.login(handleSessionResponse);
}
else
{
alert("load info");
FB.api
(
{
method: 'fql.query',
query: 'SELECT name, pic FROM profile WHERE id=' +
FB.getSession().uid
},
function(response)
{
var user = response[0];
$('
#user-info').html('<img src="' + user.pic + '">' +
user.name).show('fast');
}
);
};
});
};
function handleSessionResponse(a)
{
// if we dont have a session, just hide the user info
if (!a.session)
{
clearDisplay();
return ;
}
alert("have session");
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.127.220.20
※ 编辑: iii125 来自: 140.127.220.20 (08/19 17:04)