Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-facebook-factory

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-facebook-factory

Facebook factory for AngularJS 1.x

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

angular-facebook-factory

Facebook factory for AngularJS 1.x

Example

View auth example

Config

angular
  .module('app', ['ngFacebook'])
  .controller('AppController', ['$scope','FacebookFactory',function($scope,FacebookFactory) {
    FacebookFactory.setLang('pt_BR') // set lang
    FacebookFactory.init({
      appId: 'appId', // required, default = null
      status: true, // optional, default = true
      cookie: false, // optional, default = false
      xfbml: false, // optional, default = false
      version: 'v2.8' // optional, default = v2.4
    })
  }])

Creating service

angular
  .module('app')
  .service('FacebookService', ['$http','FacebookFactory',function($http,FacebookFactory) {
    var service = {
      me: me,
      auth: auth,
      logout: logout,
      disconnect: disconnect,
      share: share
    }
    return service
    function me(callback) {
      FacebookFactory.api('/me', {
        fields: 'name,email,gender,birthday'
      }, function(response) {
        callback(response)
      })
    }
    function auth(callback) {
      FacebookFactory.getLoginStatus(function(response) {
        if (response.status === 'connected') {
          callback(response)
        } else {
          FacebookFactory.login(function(response) {
            if (response.status === 'connected') {
              callback(response)
            }
          }, {
            scope: 'public_profile,email,user_birthday'
          })
        }
      })
    }
    function logout(callback) {
      FacebookFactory.logout(function(response) {
        callback(response)
      })
    }
    function disconnect(callback) {
      FacebookFactory.disconnect(function(response) {
        callback(response)
      })
    }
    function share(params, callback) {
      var obj = {
        method: 'share',
        mobile_iframe: true
      }
      FacebookFactory.ui(
        Object.assign(obj, params),
        function(response) {
          callback(response)
        }
      )
    }
  }])

Creating controller

angular
  .module('app')
  .controller('AuthController', ['$scope','FacebookFactory','FacebookService',function($scope,FacebookFactory,FacebookService) {
    $scope.getAuth = function(callback) {
      FacebookService.auth(function(response) {
        $scope.token = response.authResponse.accessToken // Get token
        FacebookService.me(function(response) {
          // Response handling
        })
      })
    }
    $scope.logout = function() {
      FacebookService.logout(function(response) {
        // Response handling
      })
    }
    $scope.disconnect = function() {
      FacebookService.disconnect(function(response) {
        // Response handling
      })
    }
    $scope.share = function() {
      FacebookService.share({
        href: 'http://guiseek.js.org/angular-facebook-factory',
        title: 'Angular Facebook Factory',
        description: 'Facebook factory for AngularJS 1.x'
      }, function(response) {
        // Response handling
      })
    }
  }])

Changelog

VersionDescription
1.1.0Support FB.ui to share and enhacement tasksSupports FB.ui for sharing and enhancements in npm tasks
1.0.2Method setLang on factory and better documentation

Developer

npm scripts

CommandDescription
npm startWatch and open live server
npm run watchConcat, babelify, minify and watch
npm run buildConcat, babelify and Minify

Keywords

FAQs

Package last updated on 03 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc