Start learning with our library of video tutorials taught by experts. Get started
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.
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.
There are currently no FAQs about Building Facebook Applications with PHP and MySQL.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.