-
Notifications
You must be signed in to change notification settings - Fork 3
Checkpoint 0: Get The SDK and Setup
- Google Chrome, Firefox (Please don't use IE), any standard browser with web console and inspector feature.
- Install Python 2.x version
- Proper code editor (Vim, Emacs, Sublime, Notepad++)
Code Lab Package download link: https://github.com/littleq0903/fb-js-codelab/releases/download/v1.1/fb-js-codelab.tgz
wget https://github.com/littleq0903/fb-js-codelab/releases/download/v1.1/fb-js-codelab.tgz
tar -zxf fb-js-codelab.tgz
In order to access Facebook API, you will need to apply for an API key as your credential for your application, so you have to create an app on Facebook Developer Console.
All the behavior which is connected to Facebook will be bound to your application, the one you use to generate this api key. And this API key is only available under the domains you specified, so it is not private.
To apply an API key, you need to follow these steps:
- Go to http://developers.facebook.com.
- Click Apps on the navigation bar.
- Click Add a New App
- Select Website
- Fill all the fields, except the Namespace, and click "Create App ID".
- And you will be lead to the editing app page.
- Go to Settings, and click + Add Platform
- Fill "localhost" into App Domains.
- Fill "http://localhost:8080/" into Site URL in "Website with Facebook Login", and click "Save Changes".
Back to dashboard you will see "App ID" in the top of page, copy it into your clipboard.
Create a file named "your_secret.js", and filled with the following content:
FacebookAppId = 'your-app-id';
This file will be loaded into each sample file automatically, then you don't have to create it again for each case.
After finished the above steps, you're all set.
We need to test this sample under the HTTP Protocol, so we need a simple HTTP server which could serve static files, candidates are: Nginx, Python SimpleHTTPServer, Apache.
In this practice, for running the test server locally, I will suggest you use python's built-in server, because it's easy to install and easy to launch, with this command:
python -m SimpleHTTPServer 8080
(In this code lab, we assume you run a server binding on 8080 port, so please remember to change the serving port to 8080 if you're using your own one.)