Code Monkey home page Code Monkey logo

Comments (2)

pc035860 avatar pc035860 commented on August 18, 2024

Hi @alexinm ,

This is an FB JS SDK usage issue.

The error message is caused by trying to access APIs that require you being connected to the FB app.
Which means you should call .getLoginStatus() to check if you're already connected. If not, call .login() to prompt for login/connect with Facebook.

.controller('SomeCtrl', function ($scope, ezfb, $log) {

  $scope.displayLoginButton = false;

  ezfb.getLoginStatus()
  .then(function (res) {
    if (response.status === 'connected') {
      // the user is logged in and has authenticated your
      // app, and response.authResponse supplies
      // the user's ID, a valid access token, a signed
      // request, and the time the access token 
      // and signed request each expire
      var uid = response.authResponse.userID;
      var accessToken = response.authResponse.accessToken;

      ezfb.api('/Page_ID').then(function (res) {
        $log.debug('page id result:', res);
      });

    } else if (response.status === 'not_authorized') {
      // the user is logged in to Facebook, 
      // but has not authenticated your app

      $scope.displayLoginButton = true;

    } else {
      // the user isn't logged in to Facebook.

      $scope.displayLoginButton = true;
    }
  });

})

To ensure that you access APIs with access token, always call .getLoginStatus() before any another API calls if you're calling APIs for the first time after a page load.

Refer to Facebook's official JS SDK documentation:
https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus

from angular-easyfb.

alexinm avatar alexinm commented on August 18, 2024

Hi ,
Thanks for the quick reply !
So basically the answer is what I was afraid from, I will require the user to login to see the page data.
But after spending too much time on stackoverflow I just accidently stumbled on a simple solution of
graph.facebook.com/Page_ID :) , it gives me the json with all the page data without any token or anything else .....
I'm not sure if it's a bug or a feature but it works for now

Thanks !

from angular-easyfb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.