gpt4 book ai didi

javascript - Facebook 请求权限 JavaScript?

转载 作者:行者123 更新时间:2023-11-28 02:54:45 26 4
gpt4 key购买 nike

尝试做两件事

request offline and user_events permission perminant session key

需要从 Facebook 获取事件信息,但没有 RSS。任何帮助将不胜感激!!!

目前有以下内容

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!--<title>Connect JavaScript - jQuery Login Example</title>-->
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<div>
<button id="login">Login</button>
<button id="logout">Logout</button>
<button id="disconnect">Disconnect</button>

</div>

<div id="fb-root"></div>

<script type="text/javascript">
// initialize the library with the API key
FB.init({ apiKey: 'apikey' });

// fetch the status on load
FB.getLoginStatus(handleSessionResponse);

$('#login').bind('click', function () {

FB.Connect.showPermissionDialog('publish_stream');

});

$('#logout').bind('click', function () {
FB.logout(handleSessionResponse);
});

$('#disconnect').bind('click', function () {
FB.api({ method: 'Auth.revokeAuthorization' }, function (response) {
clearDisplay();
});
});

// no user, clear display
function clearDisplay() {
$('#user-info').hide('fast');
}

// handle a session response from any of the auth related calls
function handleSessionResponse(response) {
// if we dont have a session, just hide the user info
if (!response.session) {
clearDisplay();
return;
}

// if we have a session, query for the user's profile picture and name
FB.api(
{
method: 'fql.query',

//Event pull
query: 'SELECT eid, name, tagline, pic_big, host, description, event_type, event_subtype, start_time, end_time, creator, location, venue FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid =' + FB.getSession().uid + ')'

},

function (response) {
var user = response[0];

$('#user-info').html('eid: ' + user.eid).show('fast');

}
);
}
</script>

</body>
</html>

最佳答案

我认为这对解决您的整个问题没有帮助,但是我过去使用的登录代码看起来更像是这样的:

$('#login').bind('click', function () {
FB.init({appId: "<appid goes here>", status: true, cookie: true});
FB.login(function(response) {
if (response.session) {
// user logged in, do whatever here
} else {
// user cancelled login
}
},{perms:"offline_access,user_events"});

return false;
});

关于javascript - Facebook 请求权限 JavaScript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2968841/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com