views:

57

answers:

1

I have some 3 methods.

login();
isLogin();
reply();


function isLogin(){

 FB.getLoginStatus(function(response) {  
  if (response.session) {  
    // logged in and connected user, someone you know  
  } else {  
    // no user session available, someone you dont know  
  }  
 });  
}

function login (){  
  FB.login(function(response) {  
   if (response.session) {  
    // user successfully logged in  
   } else {  
    // user cancelled login  
  }  
 });  
}


function reply(){  
  var body = 'Reading Connect JS documentation';  
  FB.api('/me/feed', 'post', { body: body }, function(response) {  
  if (!response || response.error) {  
    alert('Error occured');  
  } else {  
    alert('Post ID: ' + response);  
  }  
 });  
}  

I need, when a user will want to reply a comment then reply method will execute. before executing reply method it should test if user is login, if user is not login then execute login method and call reply method again. How can I achieve this task

Thanks in advance

A: 

you need to construct conditions that will handle the following:

When a user will want to reply a comment

  1. Check session if user isLogin()
    • if TRUE then reply method is enabled by default
    • if FALSE then call login() method via ajax for awesomeness
      • if login.success then call reply method
      • if login.failed add statement here
Mark Guadalupe