diff options
| author | Evan Chiu | 2014-10-30 21:42:42 -0400 |
|---|---|---|
| committer | Evan Chiu | 2014-10-30 21:42:42 -0400 |
| commit | 60de545f54eda6c9ce20d78030940bfaa1a34c40 (patch) | |
| tree | 08bd57771d8ffb773f0fe53bc64be3fe3a7ef447 | |
| parent | 8047bbd23022f78c081bdacaf0ab6f0054509cf7 (diff) | |
| download | sipping-point-60de545f54eda6c9ce20d78030940bfaa1a34c40.tar.bz2 | |
Added logout, loadFriends, and user_friends perm
| -rw-r--r-- | views/index.ejs | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/views/index.ejs b/views/index.ejs index 0dc0f18..4e478bc 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -6,11 +6,14 @@ <link rel='stylesheet' href='/stylesheets/style.css' /> </head> <body> +<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script> + var AUTH = {}; // This is called with the results from from FB.getLoginStatus(). function statusChangeCallback(response) { console.log('statusChangeCallback'); console.log(response); + AUTH = response.authResponse; // The response object is returned with a status field that lets the // app know the current login status of the person. // Full docs on the response object can be found in the documentation @@ -20,13 +23,11 @@ testAPI(); } else if (response.status === 'not_authorized') { // The person is logged into Facebook, but not your app. - document.getElementById('status').innerHTML = 'Please log ' + - 'into this app.'; + document.getElementById('status').innerHTML = 'Please log into this app.'; } else { // The person is not logged into Facebook, so we're not sure if // they are logged into this app or not. - document.getElementById('status').innerHTML = 'Please log ' + - 'into Facebook.'; + document.getElementById('status').innerHTML = 'Please log into Facebook.'; } } @@ -87,7 +88,21 @@ } function loadFriends() { + $.getJSON('https://graph.facebook.com/v2.2/' + + AUTH.userID + '/friends?access_token=' + + AUTH.accessToken + + '&format=json&method=get&pretty=0&suppress_http_code=1', + function(data) { + console.log(data); + } + ); + } + function logout() { + console.log('logging out'); + FB.logout(function(response) { + console.log('logged out'); + }); } </script> @@ -97,9 +112,11 @@ the FB.login() function when clicked. --> -<fb:login-button scope="public_profile,email" onlogin="checkLoginState();"> +<fb:login-button scope="public_profile,email,user_friends" onlogin="checkLoginState();"> </fb:login-button> +<input type="button" onclick="logout()" value="logout"></input> + <div id="status"> </div> |
