2010-06-03 120 views
1

試圖做兩件事情Facebook請求權限javascript?

要求離線和user_events許可 perminant會話密鑰

需要從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> 

回答

1

我不認爲這有助於你的整個問題,但是我已經在過去使用的登錄代碼看起來更像是這樣的:

$('#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; 
});