Facebook Friend List Import using fboauth I am using fboauth for enabling login with facebook for the website. Here is an overview of how I achieve the functionality:

When the user clicks on the facebook login button on the website, he or she is taken to a facebook login page. After logging in with facebook, the user is taken to the app authorization page where the user asks for permission to connect with the app. Once necessary permissions are granted, a local account (account at my website) is automatically created for the user and the user is brought back to a welcome page to set password. The user won't even have to verify their email address. On subsequent visits, when the user clicks on the login link, he/she is taken to the same facebook login page where they supply their login credentials. On successful login, they are brought back to the website. So far, everything works fine with the fboauth module.

What I am trying to achieve now is a functionality similar to what is found with the fbconnect module. The user is provided with a block/page where the user can import the list of his friends who has authorized with the app, and see the links to their local accounts (accounts at the website). How to achieve this functionality? The fboauth module has its own API which can be utilized. Here is what I already have, written using the API of fboauth. 

&lt;?php
function mymodule_fboauth_actions() {
  $actions['mymodule_friend_import'] = array(
    'title' =&gt; t('Imports your friends),
   'callback' =&gt; 'mymodule_fboauth_action_friend_import',
    'permissions' =&gt; array(
      'user_friends',
    ),
);
  return $actions;
}
function mymodule_fboauth_action_friend_import($app_id, $access_token) {
$result = fboauth_graph_query('me/friends?fields=name', $access_token);
drupal_set_message(t('Import complete!'));
}
?&gt;

This will import all the friends of a user as an object into $result. However, what I am finding it difficult is to display those names with the user's corresponding local accounts (accounts at the website). This is because of my lack of knowledge in php. What I am looking for is here is the exact lines of code that can be inserted after $result recieves its value so that the names of the users are displayed along with the links to their profile pages at my website.
The code you have there is returning friend's names which could be problematic if any of the user's friends have the same name (names like John Smith and Mohammed Abdul spring to mind).

You should change your friend import function to get the facebook user id like this:

function mymodule_fboauth_action_friend_import($app_id, $access_token) {
  $result = fboauth_graph_query('me/friends?fields=id', $access_token);
  drupal_set_message(t('Import complete!'));
}


As you rightly pointed out fboauth has a useful API including this method which turns facebook user ids into Drupal user ids:

/**
 * Load a Drupal User ID given a Facebook ID.
 */
function fboauth_uid_load($fbid) {
  $result = db_query("SELECT uid FROM {fboauth_users} WHERE fbid = :fbid", array(':fbid' =&gt; $fbid));
  $uid = $result-&gt;fetchField();
  return $uid ? (int) $uid : FALSE;
}


To make an array of Drupal user profiles you could write this in your code:

$accounts = array();
foreach($result-&gt;data as $fbuid){
  $accounts[] = user_load(fboauth_uid_load($fbuid-&gt;id));
}


How you then use those profiles depends on where you want to display them, but something like this should do the trick:

foreach($accounts as $account){
  print l($account-&gt;name, 'user/'.$account-&gt;uid);
}


If you put it all together you will have something like this - you may need to adjust some of the specifics as I do not know how you wish the information to be displayed:

&lt;?php
function mymodule_fboauth_actions() {
  $actions['mymodule_friend_import'] = array(
    'title' =&gt; t('Imports your friends'),
    'callback' =&gt; 'mymodule_fboauth_action_friend_import',
    'arguments' =&gt; array)
      'app_id' =&gt; MISSING,
      'access_token' =&gt; MISSING,
    ),
    'permissions' =&gt; array(
      'user_friends',
    ),
);
  return $actions;
}

function mymodule_fboauth_action_friend_import($app_id, $access_token) {
  $result = fboauth_graph_query('me/friends?fields=id', $access_token);
  drupal_set_message(t('Import complete!'));

  $accounts = array();
  foreach($result-&gt;data as $fbuid){
    $accounts[] = user_load(fboauth_uid_load($fbuid-&gt;id));
  }

  foreach($accounts as $account){
    print l($account-&gt;name, 'user/'.$account-&gt;uid);
  }
}


If this doesn't display anything that means print is the wrong function to use in this context.  How you get the items to display depends entirely on where and how you are calling this function.  If it's part of a hook such as hook_node_view() you can edit the node entity before it is rendered, but if (as I suspect) this function is being run in the background without refreshing the screen you will likely have to employ some JQuery or AJAX to get the relevant items to display.

I would start with this post on Javascript and JQuery for an explanation of how Drupal uses JQuery, and this post on building AJAX into non-form elements in Drupal.