You are here

function fbconnect_get_connected_friends in Facebook Connect 5

Same name and namespace in other branches
  1. 8.2 fbconnect_invite/fbconnect_invite.module \fbconnect_get_connected_friends()
  2. 6.2 fbconnect_invite/fbconnect_invite.module \fbconnect_get_connected_friends()
  3. 6 fbconnect.module \fbconnect_get_connected_friends()
  4. 7.2 fbconnect_invite/fbconnect_invite.module \fbconnect_get_connected_friends()

Get facebook friend who has_added_app.

2 calls to fbconnect_get_connected_friends()
fbconnect_block_render in ./fbconnect.module
Render data for fbconnect block
fbconnect_register_page in ./fbconnect.module
Menu callback. Called when user perform facebook registration

File

./fbconnect.module, line 982
This module allows site visitors to connect and register with facebook account

Code

function fbconnect_get_connected_friends($fbuid) {
  if (facebook_client()) {
    $query = 'SELECT uid, has_added_app FROM user WHERE uid IN ' . '(SELECT uid2 FROM friend WHERE uid1 = ' . $fbuid . ')';
    try {
      $rows = facebook_client()->api_client
        ->fql_query($query);
    } catch (Exception $e) {
      watchdog('fbconnect', 'Exception thrown while using FQL: %code', array(
        '%code' => $e
          ->getMessage(),
      ), WATCHDOG_WARNING);
    }
    if (empty($rows)) {
      return;
    }
    $friends = array();
    foreach ($rows as $row) {
      if ($row['has_added_app'] == 0) {
        continue;
      }
      if ($uid = _is_fbconnect_user($row['uid'])) {
        $user = user_load($uid);
        if ($user->fb_visibility) {
          $friends[] = $user;
        }
      }
    }
    return $friends;
  }
}