Tuesday, 6 August 2013

FB.getLoginStatus, FB.logout, FB.login not working fine

FB.getLoginStatus, FB.logout, FB.login not working fine

FB.getLoginStatus, FB.logout, FB.login not working fine. in chrome browser
with following code it works fine for one time after clicking again on
Connect/Mocdify button popup doesn't appears. and in IE browser popup is
comming but not closing automatically and data is not being render on
browser. any solution? i want to connect and reconnect facebook account
with one button.
<input type='button' onclick='connectModifyFacebookInfo()'
value='Connect/Modify Facebook Info'/>
<script>
$(document).ready(function(){
$('#datacol411').append('&lt;div id="fb-root" name="fb-root" &gt;
hi &lt;div/&gt;');
//-------------init the FB JS SDK start
FB.init({
appId : 'my app id', // App ID
from the app dashboard
channelUrl : '//localhost:7003/B001/channel.html', //
Channel file for x-domain comms
status : true, // Check
Facebook Login status
xfbml : true,
cookie : true // Look
for social plugins on the page
});
// Additional initialization code such as adding Event Listeners
goes here
// Load the SDK asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
//--------------init the FB JS SDK end.
});
function connectModifyFacebookInfo(){
FB.getLoginStatus (function(response){
if(response.status == 'connected'){
FB.logout(function(response) {
FB.login(function(response) {
FB.api('/me', function(response){
var userInfo =
document.getElementById('fb-root');
userInfo.innerHTML = '&lt;img
src="https://graph.facebook.com/' +
response.id + '/picture"/&gt;' +
response.name;
});
});
});
}else{
FB.login(function(response) {
FB.api('/me', function(response){
var userInfo = document.getElementById('fb-root');
userInfo.innerHTML = '&lt;img
src="https://graph.facebook.com/' + response.id +
'/picture"/&gt;' +
response.name;
});
});
}
});
}
<script>

No comments:

Post a Comment