Skip to content

Checkpoint 0: Get The SDK and Setup

littleq0903 edited this page Nov 27, 2014 · 6 revisions

Setup your environment

  • 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++)

Download the Code Lab Pack

Code Lab Package download link: https://github.com/littleq0903/fb-js-codelab/releases/download/v1.1/fb-js-codelab.tgz

Unix Commands:
wget https://github.com/littleq0903/fb-js-codelab/releases/download/v1.1/fb-js-codelab.tgz
tar -zxf fb-js-codelab.tgz

Apply your API key

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 credential file

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.

Run the server

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.)