Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.fbAsyncInit = function() {
- FB.init
- ({
- appId : 'APP-ID',
- status : true, // check login status
- cookie : true, // enable cookies to allow the server to access the session
- xfbml : true, // parse XFBML
- version: 'v2.2'
- });
- FB.Event.subscribe('auth.login', function()
- {
- window.location.reload();
- });
- FB.getLoginStatus(function(response) {
- if (response.status === 'connected') {
- console.log('Logged in.');
- var uid = response.authResponse.userID;
- var accessToken = response.authResponse.accessToken;
- if(typeof facebookInit !== 'undefined')
- facebookInit();
- }
- else {
- FB.login(function (response) {
- if (response.authResponse) {
- // some code here
- } else {
- alert("Login attempt failed!");
- }
- } //, { scope: 'read_stream' } // do I need to use scope here?
- );;
- }
- });
- };
- (function(d, s, id){
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) {return;}
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- function facebookInit() {
- FB.api('/PAGE-ID/feed', function(response) {
- console.log(response); // the returned array is empty
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement