function fb_actions_ref_fbml in Drupal for Facebook 5
Same name and namespace in other branches
- 5.2 fb_actions.module \fb_actions_ref_fbml()
File
- ./
fb_actions.module, line 278 - Actions defined here interact with Facebook's API. This makes it possible to notify facebook of various activities as they happen.
Code
function fb_actions_ref_fbml(&$object, $values) {
if ($values['hook'] == 'nodeapi') {
$node =& $object;
}
else {
if ($values['hook'] == 'comment') {
$node = node_load($object['nid']);
$comment =& $object;
}
else {
if ($values['hook'] == 'user') {
$account =& $object;
}
}
}
// Log into facebook as the current user.
if ($fb_app = $GLOBALS['fb_app']) {
if ($values['fb_app_nid'] == FB_APP_CURRENT || $fb_app->nid == $values['fb_app_nid']) {
// We're in a canvas page for the desired app. We're already logged in.
$fb = $GLOBALS['fb'];
}
}
if (!$fb && $values['fb_app_nid'] != FB_APP_CURRENT) {
// Need to log into this app.
$fb_app = fb_get_app(array(
'nid' => $values['fb_app_nid'],
));
$fb = fb_api_init($fb_app, FB_FBU_INFINITE_SESSION);
}
// This will be set on canvas pages and Facebook App cron actions.
if ($fb && $fb_app) {
// Replace fb_app related tokens
$body = token_replace($values['body'], 'fb_app', $fb_app);
$body = check_markup($body, $values['body_filter'], FALSE);
if ($fb_app->canvas && function_exists('fb_canvas_process_fbml')) {
$body = fb_canvas_process_fbml($body, $fb_app);
}
if (variable_get('fb_actions_verbose', FALSE)) {
watchdog('fb_actions', t('Setting Facebook ref FBML for %handle to %body', array(
'%handle' => $values['handle'],
'%body' => htmlentities($body),
)));
}
$fb->api_client
->fbml_setRefHandle($values['handle'], $body);
fb_report_errors($fb);
}
}