function fbconnect_get_connected_friends in Facebook Connect 7.2
Same name and namespace in other branches
- 8.2 fbconnect_invite/fbconnect_invite.module \fbconnect_get_connected_friends()
- 5 fbconnect.module \fbconnect_get_connected_friends()
- 6.2 fbconnect_invite/fbconnect_invite.module \fbconnect_get_connected_friends()
- 6 fbconnect.module \fbconnect_get_connected_friends()
Get facebook friend who has_added_app.
1 call to fbconnect_get_connected_friends()
- fbconnect_invite_block_view in fbconnect_invite/
fbconnect_invite.module - Implements hook_block_view().
File
- fbconnect_invite/
fbconnect_invite.module, line 171
Code
function fbconnect_get_connected_friends($fbuid) {
$fbid = array();
$rows = array();
if (facebook_client_session()) {
try {
try {
$rows = fbconnect_graph_query('/me/friends', array(
'fields' => 'id,installed',
))
->asArray();
} catch (Exception $e) {
drupal_set_message($e
->getMessage(), 'error');
throw $e;
}
} catch (Exception $e) {
$msg = 'Exception thrown while using fbconnect_get_connected_friends: @code';
$args = array(
'@code' => $e
->getMessage(),
);
watchdog('fbconnect', $msg, $args, WATCHDOG_ERROR);
}
if ($rows) {
foreach ($rows as $row) {
if ($row['has_added_app']) {
$fbid[] = $row['uid'];
}
}
if ($fbid) {
$friends = array();
$res = db_select('fbconnect_users', 'f')
->fields('f', array(
'uid',
))
->condition('f.fbuid', $fbid, 'IN')
->execute();
while ($uid = $res
->fetchField()) {
$friends[] = user_load($uid);
}
return $friends;
}
}
}
}