Skip to content

A small wrapper that wraps facebook connect in a backbone.js model

Notifications You must be signed in to change notification settings

dorongutman/facebook-user.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Facebook User Backbone.js Model

tl;dr A small wrapper that wraps facebook connect in a backbone.js model

This small lib provides a Backbone model that works with the facebook JavaScript SDK.

It can be used to connect a user via facebook, ask for permissions and retrieve profile information.

The events of the facebook SDK are converted to Backbone events so the model can easily be used with Backbone views.

Demo

Try it out yourself on the demo page

Getting Started Guide

Dependencies

Make sure you initialized the facebook SDK

FB.init({
  appId: 'YOUR-FACEBOOK-APP-ID'
})

Create a model

user = new FacebookUser()

Register to model events

// callback example:
// callback = function(model, response) {}
user.on('facebook:connected',    callback)
user.on('facebook:disconnected', callback)
user.on('facebook:unauthorized', callback)

Log the user in (opens the facebook popup)

user.login()

Log the user out

user.logout()

Fetch the facebook profile

user.fetch()

Check for Login status (e.g. after initialization)

user.updateLoginStatus()

LICENSE:

(The MIT License)

Copyright (c) 2010 Christian Bäuerlein

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A small wrapper that wraps facebook connect in a backbone.js model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%