Interactive Video Part 3: Getting the User Content from Facebook

Written by Gilles on December 5, 2011

At this step, we’ll explain how to get the user content (info and profile picture) from Facebook and cache this media on our server. We assume you have basic knowledges of the Facebook API (login, authorisation), so we’ll focus on how to get the content.

This tutorial is the third part of a series on Interactive video made with Adobe Flash and Adobe After Effects. Find the other parts here :

  1. Preparing the Videos with Adobe After Effects
  2. Developing the Player with the new AS3 API
  3. Getting the User Content from Facebook

You can download all source files here

Getting the user information and saving it in MySQL

In this tutorial, we will access Facebook’s GraphAPI using PHP. Here is an example of how to access it, assuming you have the authorisation and the user access token.

Now we want to save it a mysql database, so we’ll create a table called fb_member and a php class to store and access to these datas.
First create db and create the fb_member table by copy/pasting this sql request.

Then create a PHP class to manage its data.

This uses basic MySQL requests to save, remove and fetch users from DB, in case of large scaled project we prefer using existing frameworks.

Getting the user profile picture and saving a cache file on our server

In case of our the project, we manipulate bitmap data from facebook profile picture and this require sandbox authorisation. Facebook give these authorization Then we have use a trick to save user profile picture in our webserver and return cached image url which will be inside application sandbox.

Here is PHP sample which illustrates how we can do. In that case we use a facebook utils class called sfFacebookPhoto which take care of converting facebook image url.

Now we just have to store these info into database. here is updated version of our first FBUserData class

Again this code is really simplified for the purpose of this tutorial. This is up to you to fit this into your own project framework.

Here is sources files.

Posted Under: PHP