Advertisement
Apidcloud

Retrieve feed from facebook - sdk 4.0

Nov 23rd, 2014
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.       window.fbAsyncInit = function() {
  3.            FB.init
  4.                 ({
  5.                     appId   : 'APP-ID',
  6.                     status  : true, // check login status
  7.                     cookie  : true, // enable cookies to allow the server to access the session
  8.                     xfbml   : true, // parse XFBML
  9.                     version: 'v2.2'
  10.                 });
  11.                 FB.Event.subscribe('auth.login', function()
  12.                 {
  13.                     window.location.reload();
  14.                 });
  15.          
  16.           FB.getLoginStatus(function(response) {
  17.               if (response.status === 'connected') {
  18.                 console.log('Logged in.');
  19.                 var uid = response.authResponse.userID;
  20.                 var accessToken = response.authResponse.accessToken;
  21.  
  22.                if(typeof facebookInit !== 'undefined')
  23.                       facebookInit();
  24.               }
  25.               else {
  26.                 FB.login(function (response) {
  27.                     if (response.authResponse) {
  28.                       // some code here
  29.  
  30.                     } else {
  31.                       alert("Login attempt failed!");
  32.                     }
  33.                   } //, { scope: 'read_stream' } // do I need to use scope here?
  34.         );;
  35.                }
  36.             });
  37.         };
  38.  
  39.       (function(d, s, id){
  40.          var js, fjs = d.getElementsByTagName(s)[0];
  41.          if (d.getElementById(id)) {return;}
  42.          js = d.createElement(s); js.id = id;
  43.          js.src = "//connect.facebook.net/en_US/sdk.js";
  44.          fjs.parentNode.insertBefore(js, fjs);
  45.        }(document, 'script', 'facebook-jssdk'));
  46.      
  47.      
  48. function facebookInit() {
  49.  
  50.     FB.api('/PAGE-ID/feed', function(response) {
  51.        console.log(response); // the returned array is empty
  52. });
  53.  
  54.      
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement