You are here

function fbconnect_get_connected_friends in Facebook Connect 6

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

Get facebook friend who has_added_app.

1 call to fbconnect_get_connected_friends()
fbconnect_block in ./fbconnect.module
Implementation of hook_block().

File

./fbconnect.module, line 154

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) {
      $msg = 'Exception thrown while using fbconnect_get_connected_friends: @code';
      $args = array(
        '@code' => $e
          ->getMessage(),
      );
      watchdog('fbconnect', $msg, $args, WATCHDOG_WARNING);
    }
    if ($rows) {
      foreach ($rows as $row) {
        if ($row['has_added_app']) {
          $fbid[] = $row['uid'];
        }
      }
      if ($fbid) {
        $res = db_query('SELECT uid FROM {fbconnect_users} WHERE fbuid IN (' . implode($fbid, ',') . ')');
        while ($uid = db_result($res)) {
          $user = user_load($uid);
          if ($user->fb_visible) {
            $friends[] = $user;
          }
        }
        return $friends;
      }
    }
  }
}