Skip to content

Commit

Permalink
#89
Browse files Browse the repository at this point in the history
- Remove unused scopes
- Update API to v3.0
- Remove comments in JS
  • Loading branch information
Paul Radt committed Jun 29, 2018
1 parent 7aab872 commit 810297d
Showing 1 changed file with 6 additions and 34 deletions.
40 changes: 6 additions & 34 deletions Resources/views/Block/facebook_auth.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="box-body">
<div class="sonata-ba-collapsed-fields">
<div class="form-group">
<fb:login-button scope="public_profile,email,manage_pages,publish_pages,user_videos,user_events,user_managed_groups,publish_actions" onlogin="checkLoginState();" autologoutlink="true"></fb:login-button>
<fb:login-button scope="public_profile,email,publish_pages,user_events" onlogin="checkLoginState();" autologoutlink="true"></fb:login-button>
</div>
<div class="form-group">
<select id="livebroadcast-fb-entity-select">
Expand All @@ -19,31 +19,19 @@

{% block facebook_js %}
<script type="text/javascript">
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
// 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
// for FB.getLoginStatus().
$('#livebroadcast-fb-entity-select').html('<option>Select your Facebook entity</option>');
if (response.status === 'connected') {
document.getElementById('fb-status').innerHTML = 'Login with Facebook and choose from your available Facebook entities.';
// Logged into your app and Facebook.
getAccountsForLoggedInUser();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('fb-status').innerHTML = 'Please request Facebook access from your Live Stream app maintainer.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('fb-status').innerHTML = 'Please log into Facebook.';
}
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
Expand All @@ -53,24 +41,11 @@
window.fbAsyncInit = function() {
FB.init({
appId : '{{ facebookAppId }}',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.5' // use graph api version 2.5
cookie : true,
xfbml : true,
version : 'v3.0'
});
// Now that we've initialized the JavaScript SDK, we call
// FB.getLoginStatus(). This function gets the state of the
// person visiting this page and can return one of three states to
// the callback you provide. They can be:
//
// 1. Logged into your app ('connected')
// 2. Logged into Facebook, but not your app ('not_authorized')
// 3. Not logged into Facebook and can't tell if they are logged into
// your app or not.
//
// These three cases are handled in the callback function.
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
Expand All @@ -86,7 +61,6 @@
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
Expand All @@ -95,8 +69,6 @@
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function getAccountsForLoggedInUser() {
var channel, option;
Expand Down Expand Up @@ -137,7 +109,7 @@
/* Retrieve page access tokens with the long lived user access token */
FB.api('/me/accounts', {access_token: data.accessToken }, makeAccountSelectable);
FB.api('/me/admined_groups', makeGroupsSelectable);
FB.api('/me/groups', makeGroupsSelectable);
FB.api('/me/events', makeEventsSelectable);
}
});
Expand Down Expand Up @@ -183,7 +155,7 @@
if (response.paging && response.paging.next) {
var params = getUrlVars(response.paging.next);
FB.api('/me/admined_groups', params, makeGroupsSelectable)
FB.api('/me/groups', params, makeGroupsSelectable)
}
}
Expand Down

0 comments on commit 810297d

Please sign in to comment.