Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Constructing paths with the Graph API Explorer

From: Building Facebook Applications with PHP and MySQL

Video: Constructing paths with the Graph API Explorer

So far we've learned that we can access open graph data by making a request to the Open Graph API with a path. The best way to construct an experiment with paths is through a tool Facebook has built for developers called the Open Graph API Explorer, so let's take a look. You can get to this tool by going to this URL. If you watch the movie on using Graph API paths, you know how to construct simple paths to send to the Graph API and pull up different types of data from the Social Graph. This tool let's you quickly try out connections and view sample data for different users, it also let's you create temporary access tokens that you can use to make some of the connections that require certain permissions. You should already see a sample path in the input field as well as an access token.

Constructing paths with the Graph API Explorer

So far we've learned that we can access open graph data by making a request to the Open Graph API with a path. The best way to construct an experiment with paths is through a tool Facebook has built for developers called the Open Graph API Explorer, so let's take a look. You can get to this tool by going to this URL. If you watch the movie on using Graph API paths, you know how to construct simple paths to send to the Graph API and pull up different types of data from the Social Graph. This tool let's you quickly try out connections and view sample data for different users, it also let's you create temporary access tokens that you can use to make some of the connections that require certain permissions. You should already see a sample path in the input field as well as an access token.

At the very top of the window there is a pop-up menu where you can choose the application the access token should belong to. You can switch it to pretend that one of your current applications requested the token that allows you to approximate how this app would work if you're page asked for access. If you hit the Debug button, you'll be taken to a new page, it shows you information about the current access token. At the bottom you can see the scope for the access token that's the permissions this application has, let's close the Debug window.

We can change the permissions we ask for by hitting the Get Access Token button and choosing from the list of permissions available to us. There are three categories of permissions, User Data Permissions, Friends Data Permissions, and Extended Permissions. This is also a good place to check out the names of specific permissions you want to request. Most of the time you can figure out which permissions you need for which data by reading the permissions, but sometimes you need to consult the API Graph documentation that's at this URL.

On this page you want to click on the object you want on the left-hand side and then read any special notes on permissions on the right. So if you pick Photos, you can see that we need the user photos permission to access the photos and albums uploaded by the user, as well as photos in which the user has been tagged. Let's go back to the API Explorer. Right underneath the access token area, we can choose whether we want to query Facebook with the Graph API or FQL Query, the Facebook Query Language. That means that you can also use this page to test out your FQL queries.

Underneath that you can choose to issue a GET, POST, or DELETE request. Doing different things like posting to a user's wall or deleting items requires different types of requests. To the right of that you'll see the path that you should use in your application to make that type of request. Underneath there's a list of items you're requesting, at the bottom of this list is a plus sign, let's choose email from this list. Now we'll need to hit the Submit button to submit this new path. If you already have permissions for an email address, you'll see the email come up right here.

Let's add another permission here. Occasionally, you'll see a field that doesn't result any data. This happens for one of two reasons. Either you don't have the right permission to retrieve this information or the user has not filled this out in their profile. In both cases the field will be grayed out. So make sure you check out the API Reference to see if those fields require any special permission. You can always go back and click on Get Access Token and add additional permissions for different things.

Let's try another one, hit the Submit button. So here we didn't get a birthday for this user, not because they didn't enter that information, but because we don't have the right permissions, so let's get another Access Token here and make sure that we include user birthday. It's going to give me a dialog box to make sure that I allow those permission to the Open Graph API, so I'll hit Allow. It takes me back here, and now I'll resubmit this request, and now we can see this user's birthday.

Let's try something else. We'll try connection this time like Posts. So occasionally with something like posts, you'll see a sub plus sign, you can choose additional items from this list to see subcategories underneath posts. You can also do things like limit how many results we get back, and you can see the path being built with that information. So the Open Graph API is not only showing you how to build certain paths, but also how to limit certain paths and add additional information.

Here we can see the next 25 posts. So the Open Graph API Explorer is a really powerful way to visually construct and test paths for your Facebook Application. Make sure to take some time to play around with it and explore what can be done with this awesome tool.

Show transcript

This video is part of

Image for Building Facebook Applications with PHP and MySQL
Building Facebook Applications with PHP and MySQL

24 video lessons · 8262 viewers

Ray Villalobos
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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.


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.

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

Your file was successfully uploaded.

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.