Skip to content

Xowap/FreneticBunny

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FreneticBunny

Introduction

Frennetic Bunny is a Facebook helper for jQuery. It was made out of frustration trying to connect a user within a Facebook application.

The goal was to make Facebook login & permissions management as simple as this:

$.fb.connected('email').done(function () {
	// Do something useful here now that your user is connected
}).fail(function () {
	console.log('The user did reject us!');
});

It strongly relies on jQuery's promises: instead of giving instructions, you just ask the library to guarantee a certain state, and everything else is handled automatically.

Licence

Copyright © 2013 Rémy Sanchez remy.sanchez@hyperthese.net

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.

Structure

This library allows you to get a jQuery promise at different stages of the Facebook initialization process, to make sure that you get what you need, while keeping a totally asynchronous loading. The stages are the following:

`$.fb.loaded()`
The Facebook javascript file has been loaded
`$.fb.initialized()`
FB.init() was called
`$.fb.authenticated()`
At this stage, the library knows if the user has installed the app or not.
`$.fb.connected(perms)`
Returns a promise that ensures that the user gives the asked permissions.

If you call any of those methods, it will implicitly trigger all the steps required in order to reach that stage. It means that is you did not load Facebook yet, calling $.fb.connected() will load & init Facebook on its own. This can be a way of lazy loading the Facebook API only when needed.

There is also a simple shortcut named $.fb.ready(fn) that works exactly the way you think: it will execute fn only when Facebook has been loaded.

Before calling any of those methods though, you have to setup the thing. Typically:

// This gives the settings
$.fb.setup({
	appId: 42, // That's your app ID from your dev interface
	channelUrl: '//mywebsite.com/channel.html', // see https://developers.facebook.com/docs/reference/javascript/#channel
	locale: 'en_US',
	serverSignedRequest: <?php echo json_encode($_REQUEST['signed_request']); ?>
});

// And this initializes Facebook
$.fb.initialized();

Going further

There is a example/index.php that will show you a bit how to use the library. Otherwise feel free to contact me directly.

About

Frennetic Bunny is a Facebook helper for jQuery

Resources

Stars

Watchers

Forks

Packages

No packages published