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

Building Facebook Applications with PHP and MySQL

Understanding Graph API paths


From:

Building Facebook Applications with PHP and MySQL

with Ray Villalobos

Video: Understanding Graph API paths

Facebook stores information about users and their connections in something known as the Social Graph. It's sometimes also called the Open Graph. To access that data, Facebook provides something called the Open Graph API. In the previous video we learned how to access data about the user by using a path called /me, which is a shortcut to the current user. Let's take a look at how to use other paths to get different types of information from Facebook. The paths we're using /me looks suspiciously like the end of URL, and it is.

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 PHP and MySQL
1h 45m Intermediate Jan 16, 2013

Viewers: in countries Watching now:

Learn the basics of building complex, data-driven applications with the Facebook PHP SDK and MySQL. Author Ray Villalobos first introduces the fundamentals, such as checking to see if a user is logged into an application, accessing Facebook user data through the Open Graph API, and making complex API calls with the Graph API Explorer. The course then dives into building an application with API paths and Facebook Query Language (FQL) calls. Along the way, you'll discover how to post to a user's wall, upload photos, integrate with webpages, and more.

Topics include:
  • Downloading and installing the PHP SDK
  • Logging in and authenticating users
  • Accessing Open Graph data
  • Working with connection subpaths, limits, and subsearches
  • Styling a Facebook app with CSS
  • Setting up pagination
  • Understanding Facebook Query Language (FQL)
  • Integrating query results into a full-scale application
Subjects:
Developer Web Databases Web Development
Software:
Facebook MySQL PHP
Author:
Ray Villalobos

Understanding Graph API paths

Facebook stores information about users and their connections in something known as the Social Graph. It's sometimes also called the Open Graph. To access that data, Facebook provides something called the Open Graph API. In the previous video we learned how to access data about the user by using a path called /me, which is a shortcut to the current user. Let's take a look at how to use other paths to get different types of information from Facebook. The paths we're using /me looks suspiciously like the end of URL, and it is.

Facebook takes our path and sends it to an application at graph.facebook.com, so we can use that URL with different paths to get some public information about the Facebook object, plus, we can also build our own paths. If you take a look at the API Reference, you can see some examples of other paths you can use to retrieve data. If you click on one of these URLs, you'll see the results displayed as JSONobjects, which are similar to PHP associative arrays. So we can use the username of any existing Facebook account and get some basic data about that user.

We could use a username stuart.beland, and we would get the info for our current Facebook user. Now instead of the User Name, we can also use a User ID, so I'm going to grab the User ID from our application and then come over here and just paste that right there. So if you know your User ID or your User Name, you can try that as a call to graph.facebook.com. If you look at the rest of this list, there is a lot of different information we can get from other pages, so this, for example is a Coca-Cola page, and you can see some generic information here from a page, instead of a user.

There's a link to groups, photos, photo albums, and other things you can get from the Graph API. In addition to accessing objects, we can also access an object connection, you can see that there are paths here for different things, like friends, a profile or a wall, likes, books, et cetera. Now these paths to connections require access tokens or permissions, you can't just do this with any user, but at least on this page you can explore some of them. As long as you have permissions to get this user data, you can use these in your applications as well.

You don't always need to get all of the information from a user, you can also limit the fields the call returns. So let me try a page I created for BarCamp event in my area. Now we can limit the fields by passing along the field variables with a value and a description, so I'm going to add a question mark here and just type in the fields that I want. That sometimes makes it easier to get just the information we need and reduces the overall size of the data we retrieve. You can also ask for information from multiple IDs, like more than one user.

To get a clear understanding of how to work with each object and its connection, take a look at the left side of the Graph API Reference, each object is listed there. If you click on an object you can see its permission requirements. To read the photo object we need a valid access token, as well as the user photos permission, if we want to access photos and albums uploaded by a user, as well as the friends_photos permissions to access their friend's photos and photos in which the user has been tagged. You can also publish a photo if you have a publish stream permission.

These are all permissions that you can ask for in your applications, you can also see a list of all the fields you can get from that data and types of connections, as well as ways to create and do things like delete some of these objects. Paths are a really powerful way to access data inside the Open Graph, any developer that has used a HTTP post or get methods should be able to pick up the syntax in no time.

There are currently no FAQs about Building Facebook Applications with PHP and MySQL.

Share a link to this course
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

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 PHP and MySQL.

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
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



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.

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