I am creating a travel planning website and I would like to have a block for users that have connected with Facebook Connect. The block would display a list of links that would say "Plan a trip to..." and then it would list a destination that was parsed from their profile data. So, I would have a list of destination names and I would match against that and provide links to create a trip node for that destination. While I know that some of this, like the destination list and parsing is outside the perview of these modules, does DFF provide some way to pull back the user's data so that it can be parsed like that?

One example of a site that does something similar is http://www.welcometofc.com/ which pulls pictures and and profile data and incorporates it into a flash "trailer".

Thanks in advance.

Comments

Dave Cohen’s picture

Browse the facebook developer wiki. See what you can learn from the API. Check out the FQL queries which are the most flexible ways to get at facebook's data. At least the data they are willing to share.

Then, use Drupal for Facebook to set up Facebook Connect. Once you have facebook connect on the pages, write a custom module to do the FQL queries (or whatever). On each page, you'll have a global variable called $fb which let's you access facebook's API.

Make sense?

pyrello’s picture

I got this working on the other site that I am currently working on.

I decided to go with something easier than FQL first, I just used the get_friends() function to pull a list of the current user's friends. It doesn't have any error checking, but an example of this working is at:

http://apps.facebook.com/ournewspaperarchive/fb/friend-search

In case anyone wants to know, here is the code that I used (again, no error handling is used yet, if you visit the page and you are not logged in, you will see an error):

global $fb;
$friends = $fb->api_client->friends_get();
$user_details = $fb->api_client->users_getInfo($friends, 'last_name, first_name, pic_square_with_logo');
$links = "";
foreach($user_details as $friend) {
$profile_pic = $friend['pic_square_with_logo'];
$first = $friend['first_name'];
$last = $friend['last_name'];
$links .= l("<img src='$profile_pic' alt='$first $last' />","http://www.newspaperarchive.com/searchResultsV3.aspx", array('query' => array('lname' => $last, 'fname' => $first),'attributes' => array('title' => "Search for $first $last in NewspaperARCHIVE"), 'html' => TRUE));
}
return $links;
lape’s picture

Status: Active » Closed (fixed)
joeysantiago’s picture

Ehm... i'm trying to pull user pictures and show them in a block. in my custom module the global $fb object is NULL... could you please help me out?

the branch i'm using is Branch: 6.x-3.x (version 3.x for Drupal 6.x)

thanks a lot

found out: the object is $_fb! :)