<h1>Login, Logout, Name and Profile Picture</h1>
<div id="account-info"></div>
<script>
function showAccountInfo() {
FB.api(
{
method: 'fql.query',
query: 'SELECT name, pic_square FROM user WHERE uid='+FB.getUserID()
},
function(response) {
Log.info('API Callback', response);
document.getElementById('account-info').innerHTML = (
'<img src="' + response[0].pic_square + '"> ' +
response[0].name +
' <button class="btn" onclick="FB.logout()">Logout</button>'
);
}
);
}
function showLoginButton() {
document.getElementById('account-info').innerHTML = (
'<button class="btn btn-primary" onclick="FB.login()">Login</button>'
);
}
function onStatus(response) {
Log.info('onStatus', response);
if (response.status === 'connected') {
showAccountInfo();
} else {
showLoginButton();
}
}
FB.getLoginStatus(function(response) {
onStatus(response);
FB.Event.subscribe('auth.statusChange', onStatus);
});
</script>
Global Var
الأحد، 3 مارس 2013
Login, Logout, Name and Profile Picture Login, Logout, Name and Profile Picture
مرسلة بواسطة
Tito Gfx
في
12:11 م
الاشتراك في:
تعليقات الرسالة (Atom)
0 التعليقات:
إرسال تعليق