https://github.com/handstandsam/exploringthefacebookapi
https://github.com/handstandsam/exploringthefacebookapi
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/handstandsam/exploringthefacebookapi
- Owner: handstandsam
- Created: 2014-11-14T13:06:35.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-11-18T21:35:42.000Z (over 11 years ago)
- Last Synced: 2025-07-05T08:42:17.419Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://www.youtube.com/watch?v=brgkRqYgVDs
- Size: 10.8 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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;
});