An open API service indexing awesome lists of open source software.

https://github.com/handstandsam/exploringthefacebookapi


https://github.com/handstandsam/exploringthefacebookapi

Last synced: 22 days ago
JSON representation

Awesome Lists containing this project

README

          

ExploringTheFacebookAPI
=======================
Author: Sam Edwards - @HandstandSam

This is an example project to be used with a presentation for the API Craft RVA meetup on November 18th, 2014.

Links


  • Online Version of the example project: http://fbapi.htechlabs.com

  • Meetup Link: http://www.meetup.com/API-Craft-RVA/events/214759532/

  • Facebook Developers Page: https://developers.facebook.com/

  • Facebook API Explorer: https://developers.facebook.com/tools/explorer

Libraries Used:


  • AngularJS 1.2.26 - https://angularjs.org/

  • Bootstrap 3.3.1 - http://getbootstrap.com/

  • Facebook JS SDK - https://developers.facebook.com/docs/javascript


Create a Facebook Application ID
https://developers.facebook.com/quickstarts/?platform=web

Redirect dev.com to your local machine to allow for development
You can use any domain youwant, dev.com is what I chose. "localhost" cannot be used, that's why we have to do this.

sudo /etc/hosts

127.0.0.1 dev.com


Initialize Facebook JavaScript SDK


window.fbAsyncInit = function () {
FB.init({
appId: '{YOUR_APP_ID}',
version: 'v2.2'
});
};

(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

Facebook Login Call


FB.login(function(response) {
console.log(response);
if (response.authResponse) {
console.log('Logged in.');
var accessToken = response.authResponse.accessToken;
console.log("Access Token: " + accessToken);
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {
scope: "public_profile,email"
//scope: "public_profile,email,user_birthday,user_about_me,user_status,user_location,user_hometown,user_birthday,user_website"
});

Current User


FB.api('/me', function(response) {
console.log(response);
var fb_user = response;
});

Current Permissions for App


FB.api('/me/permissions', function(response) {
console.log(response);
var fb_permissions = response;
});