MooFB 0.0

Takes advantage of Facebook Connect api to ease make use of it.



Details

Author
Luis Carlos Osorio Jayk
Current version
0.0
GitHub
Ciul/MooFB
Downloads
1827
Category
Utilities
Tags
Report
GitHub Issues

Releases


Dependencies

  • _self_/_current_:
    • Core/Class
    • Core/Object

How to use

First you need to follow Facebook instructions on how to include it on a site.
You can read about at http://developers.facebook.com/docs/

As a simple example, you could use the following lines at Document Head:

<html>
    <head>
        <title>My Fantastic Facebook App</title>
        <script type="text/javascript" src="mootools-core.js" />
        <script type="text/javascript" src="Class.SubObjectMapping.js" />
        <script type="text/javascript" src="MooFB.js" />

        [... whatever else you have in your document head]
    </head>

    <body>
        <h1>Connect JavaScript - MooTools Login Example</h1>
        <div>
          <button id="login">Login</button>
          <button id="logout">Logout</button>
          <button id="perms">Ask for perms</button>
        </div>

        [... whatever else code you have in your document body]
    </body>
</html>

You have to register a Facebook app at (you have to login to Facebook): http://www.facebook.com/developers/createapp.php
then use the Facebook app id to create an instance of MooFB this way:
var moofb = new MooFB.Base(myFBAppId);

My personal recommendation is that use automatic options, which are enabled by default.
Otherwise you would have to read how to include and load the Facebook api by yourself.

Facebook documentation is a little messy but with some effort you can find what you need.
Read about at: http://developers.facebook.com/docs/reference/javascript/

How To Make Api Calls

After you FB api has loaded, you can call for other methods, like login, logout, etc:

$('login').addEvent('click', function() {
    moofb.login(function(response) {
        if(response.session) {
            if(response.perms) {
                console.log(response);
            }
        }
    }.bind(moofb));
});

Or better make use of events for asynchronous calls:

var moofb = new MooFB.Base(myFBAppId).addEvents({
    login: function(response) {
        console.log(response);
    },
    logout: function(response) {
        console.log(response);
    }
});

How To Ask For Permissions

$('perms').addEvent('click', function() {
    moofb.login(function(response) {
        if(response.session) {
            if(response.perms) {

            }
        }
    }.bind(moofb), {perms: 'read_stream,publish_stream'});
});

You can see the whole table of permissions you can request at http://developers.facebook.com/docs/authentication/permissions/

Coming Soon

You can already request for user's data, pictures, albums and other, but, I'm writing a class to make it even easier.
Please be patient.

Donations

Donations are welcome. By donating you contribute to this and other Open Source efforts.

Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus