New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

Building Facebook Applications with HTML and JavaScript
Illustration by

Building Facebook Applications with HTML and JavaScript

with Ray Villalobos

Video: Welcome

Hey there! This is Ray Villalobos, and welcome to Building Facebook Applications with JavaScript. In this course we'll look at how to build Facebook applications using the JavaScript APIs and JavaScript SDK. I'll start by showing you how Facebook applications work and how Facebook stores data through the social graph. Then I'll show you how to register users and ask them to authorize your application using authorization dialogs. We'll also see how to use JSON to read data from the Facebook social graph and generate content for your app using YouTube and WordPress JSON feeds.
Expand all | Collapse all
  1. 2m 41s
    1. Welcome
      46s
    2. Using the exercise files
      1m 55s
  2. 8m 35s
    1. Introducing Facebook applications
      3m 10s
    2. Understanding the social graph
      2m 32s
    3. Working with the Facebook APIs
      2m 53s
  3. 20m 3s
    1. Installing the Facebook Developer App
      1m 57s
    2. Creating a container for your application
      4m 42s
    3. Getting and setting up a web host
      4m 33s
    4. Creating a basic app page
      8m 51s
  4. 33m 51s
    1. Loading up the JavaScript SDK and initializing Facebook
      7m 14s
    2. Checking for registered users
      7m 21s
    3. Using the OAuth dialog
      8m 31s
    4. Exploring Canvas app authorization and data output
      10m 45s
  5. 46m 17s
    1. Introducing JSON
      2m 17s
    2. Creating Open Graph data with the Graph API Explorer
      7m 11s
    3. Creating the app's shell
      5m 47s
    4. Adding a JSON video feed with YouTube APIs
      15m 6s
    5. Debugging cross-browser security issues
      4m 44s
    6. Installing the WordPress JSON plug-in
      4m 2s
    7. Adding a JSON post feed onto a page
      7m 10s
  6. 12m 30s
    1. Introducing social plug-ins in your app
      5m 46s
    2. Adding the Facepile and Comments social plug-ins
      3m 31s
    3. Creating a live event chat
      3m 13s
  7. 13m 22s
    1. Posting to a user's timeline with the Feed dialog
      4m 56s
    2. Sending a message to a friend
      3m 14s
    3. Sending invitations with the Request dialog
      5m 12s
  8. 42m 28s
    1. Creating achievements
      6m 8s
    2. Debugging with the Debugger
      2m 59s
    3. Getting an app token with JavaScript and PHP
      7m 3s
    4. Registering an achievement
      4m 15s
    5. Showing available achievements on your page
      11m 5s
    6. Assigning and displaying achievements
      10m 58s
  9. 1m 5s
    1. Next steps
      1m 5s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
Building Facebook Applications with HTML and JavaScript
3h 0m Intermediate Jun 14, 2012

Viewers: in countries Watching now:

Facebook application development is one of the most lucrative and fast-paced niches of the programming world. This course introduces developers and designers who are already familiar with HTML and JavaScript to Facebook app development. Author Ray Villalobos reviews the different types of Facebook apps and tours the Facebook Developer site, reviewing the requirements to be an apps developer. At the end of the course, Ray shows how to create a complete app, from building the initial containers and pages to adding social plug-ins and game controls.

Topics include:
  • Working with the Facebook API
  • Creating a container for an app
  • Creating the basic app page
  • Loading up the JavaScript SDK and initializing Facebook
  • Checking for registered users
  • Adding JSON data feeds
  • Adding social plug-ins
  • Creating feedback with the Feed, Message, and Request dialogs
  • Creating achievements for the app
  • Debugging the app
Subjects:
Developer Web Programming Languages Web Development
Software:
Facebook
Author:
Ray Villalobos

Welcome

Hey there! This is Ray Villalobos, and welcome to Building Facebook Applications with JavaScript. In this course we'll look at how to build Facebook applications using the JavaScript APIs and JavaScript SDK. I'll start by showing you how Facebook applications work and how Facebook stores data through the social graph. Then I'll show you how to register users and ask them to authorize your application using authorization dialogs. We'll also see how to use JSON to read data from the Facebook social graph and generate content for your app using YouTube and WordPress JSON feeds.

Finally, I'll show you how to add social plug-ins, dialogs, and create achievements for your Facebook application. We'll be covering all these features and lots more, so let's get started with Building Facebook Applications with JavaScript.

Find answers to the most frequently asked questions about Building Facebook Applications with HTML and JavaScript.


Expand all | Collapse all
please wait ...
Q: It seems to me there is something wrong either with the code provided in the exercise files or that Facebook was updated and the code provided in not valid anymore.

This is the error in the console and nothing is happening:
1- semantic issue unexpected token '}'
2- Unexpected EOF

I tried to include an alert that never worked, and tried to put the alert in the first line of the cod, which also never worked. After deleting the code completely and leaving the alert line, the alert works fine. What's going on?
A: The url here doesn't return any results.
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=populateVideos&max-results=7&category=Villalobos

However if you do this, it will return results:
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=populateVideos&max-results=7

It may be that whoever manages the channel has modified the way videos are tagged so that they no longer have the author's last name as one of the keywords. The following works as well:
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=populateVideos&max-results=7&category=Education

The code on the course is still solid, but you might have to try a different category or make sure that you just use a channel search without the category keyword.
 
Also, when you paste the URL in something like JSONLint, you have to remove the callback and alt parameters to read something like this:
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json&max-results=7

instead of this:
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=populateVideos&max-results=7

The difference is that you specify the format as alt=json and no callback. The longer version of the code is assuming that you want to use this in a <script> call that calls back a function called populateVideos, so when it returns the code, it starts like this:

APIcallbackpopulateVideos{()}

This technique of wrapping the JSON in a function called is called JSONP. The author's next course on JavaScript and JSON will explain this further.
Q: First when I pasted the url in jsonlint.com per the tutorial i got the error:

Parse error on line 1:
//APIcallbackpopulat
^
Expecting '{', '['

However I kept following along with the tutorial and trying to load videos from YouTube when I received the error:

data.entry.length is undefined.

What's going on?
A: The url here doesn't return any results.
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=populateVideos&max-results=7&category=Villalobos

However if you do this, it will return results:
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=populateVideos&max-results=7

It may be that whoever manages the channel has modified the way videos are tagged so that they no longer have the author's last name as one of the keywords. The following works as well:
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=populateVideos&max-results=7&category=Education

The code on the course is still solid, but you might have to try a different category or make sure that you just use a channel search without the category keyword.
 
Also, when you paste the URL in something like JSONLint, you have to remove the callback and alt parameters to read something like this:
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json&max-results=7

instead of this:
http://gdata.youtube.com/feeds/users/lynda/uploads?alt=json-in-script&callback=populateVideos&max-results=7

The difference is that you specify the format as alt=json and no callback. The longer version of the code is assuming that you want to use this in a <script> call that calls back a function called populateVideos, so when it returns the code, it starts like this:

APIcallbackpopulateVideos{()}

This technique of wrapping the JSON in a function called is called JSONP. The author's next course on JavaScript and JSON will explain this further.
 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Building Facebook Applications with HTML and JavaScript.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.