Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- window.fbAsyncInit = function() {
- FB.init({
- appId : '190670741097534', // App ID
- channelUrl : '//www.wtf-teen.com/channel.html', // Channel File
- status : true, // check login status
- cookie : true, // enable cookies to allow the server to access the session
- xfbml : true // parse XFBML
- });
- FB.Event.subscribe('auth.authResponseChange', function(response) {
- // Here we specify what we do with the response anytime this event occurs.
- if (response.status === 'connected') {
- testAPI();
- location.reload();
- } else if (response.status === 'not_authorized') {
- FB.login();
- } else {
- FB.login();
- }
- }, {scope: 'publish_actions'});
- };
- // Load the SDK asynchronously
- (function(d){
- var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
- if (d.getElementById(id)) {return;}
- js = d.createElement('script'); js.id = id; js.async = true;
- js.src = "//connect.facebook.net/en_US/all.js";
- ref.parentNode.insertBefore(js, ref);
- }(document));
- // Here we run a very simple test of the Graph API after login is successful.
- // This testAPI() function is only called in those cases.
- function testAPI() {
- console.log('Welcome! Fetching your information.... ');
- FB.api('/me', function(response) {
- console.log('Good to see you, ' + response.name + '.');
- });
- }
- function addPerm(perm){
- FB.login(function (response) {
- if(response.authResponse){
- // handle the response
- if(document.getElementById(''+perm+'add')){
- document.getElementById(''+perm+'add').innerHTML = "" + response.status;
- }else{
- document.getElementById('response_object').innerHTML = "" + response.status;
- }
- if(response.status==='connected'){
- location.reload();
- }
- }
- },{scope: ''+perm+''});
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement