Newer
Older
Dave Cohen
committed
<?php
/**
* @file
*
* Actions defined here interact with Facebook's API. This makes it
* possible to notify facebook of various activities as they happen.
*/
function fb_actions_action_info() {
return array('fb_actions_minifeed' =>
array('type' => 'fb_action',
'description' => t('Post to Facebook mini-feed'),
'configurable' => TRUE,
'hooks' => array('nodeapi' => array('delete', 'insert', 'update', 'view'),
'comment' => array('delete', 'insert', 'update', 'view'),
'user' => array('insert', 'update', 'delete', 'login', 'logout'),
),
),
'fb_actions_profile_fbml' =>
array('type' => 'fb_action',
'description' => t('Write to Facebook profile'),
'configurable' => TRUE,
'hooks' => array('nodeapi' => array('delete', 'insert', 'update', 'view'),
'comment' => array('delete', 'insert', 'update', 'view'),
'user' => array('insert', 'update', 'delete', 'login', 'logout'),
),
),
'fb_actions_ref_fbml' =>
array('type' => 'fb_action',
'description' => t('Write to Facebook reference FBML'),
'configurable' => TRUE,
'hooks' => array('nodeapi' => array('delete', 'insert', 'update', 'view'),
'comment' => array('delete', 'insert', 'update', 'view'),
'user' => array('insert', 'update', 'delete', 'login', 'logout'),
),
),
'fb_actions_cron_per_user' =>
array('type' => 'fb_app',
'description' => t('Perform an Action once for each user of a Facebook App'),
'configurable' => TRUE,
'hooks' => array('cron' => array('run')),
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
function fb_actions_minifeed($values = array(), &$object) {
// drupal_set_message("fb_actions_minifeed" . dpr($values, 1) . dpr($object, 1)); // debug
if ($values['hook'] == 'nodeapi') {
$node = $values['node'];
}
else if ($values['hook'] == 'comment') {
$comment = $values['comment'];
$node = node_load($comment->nid);
}
else if ($values['hook'] == 'user') {
$account = $values['user'];
}
// 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) {
global $user;
// Need to log into this app.
$fb_app = fb_get_app(array('nid' => $values['fb_app_nid']));
$fbu = fb_get_fbu($user->uid, $fb_app);
if ($fbu) {
$fb = fb_api_init($fb_app, $fbu);
}
}
// Even if we have an $fb now, it may not have permission to do all things
// we ask of it.
if ($fb) {
// Replace both node and fb_app related tokens
$title = token_replace($values['title'], 'node', $node);
$title = token_replace($title, 'comment', $comment);
$title = token_replace($title, 'user', $account);
$title = token_replace($title, 'fb_app', $fb_app);
$body = token_replace($values['body'], 'node', $node);
$body = token_replace($body, 'comment', $comment);
$body = token_replace($body, 'user', $account);
$body = token_replace($body, 'fb_app', $fb_app);
$fb->api_client->feed_publishActionOfUser($title, $body);
fb_report_errors($fb);
}
}
function fb_actions_minifeed_form($values) {
$options = fb_get_app_options(TRUE);
$form['description'] = array('#value' => t('Note that this action will only succeed when executed from a Facebook canvas page when the user is logged in, or on non-canvas pages when the logged in user has an infinite session key. These are privacy restrictions enforced by the Facebook API.'));
$form['fb_app_nid'] =
array('#type' => 'select',
'#title' => t('Application'),
'#default_value' => $values['fb_app_nid'],
'#options' => $options,
'#description' => t('Log into Facebook as which action? If %current, action will only be performed only on canvas pages.',
array('%current' => $options[FB_APP_CURRENT])),
);
$form['title'] = array('#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $values['title'],
'#description' => t('Title line of mini-feed item. (Most Facebook mini-feed items have only a title, and no message body).'),
'#required' => TRUE,
);
$form['body'] = array('#type' => 'textarea',
'#title' => t('Body'),
'#default_value' => $values['body'],
'#description' => t('Text to publish on mini-feed. In many cases, only the title is required and this may be left blank.<br />The following tokens will be replaced: !token_help',
array('!token_help' => theme('token_help', 'node') . theme('token_help', 'comment') . theme('token_help', 'fb_app'))),
);
return $form;
}
function fb_actions_minifeed_validate($form_id, $values) {
}
function fb_actions_minifeed_submit($form_id, $values) {
return array('fb_app_nid' => $values['fb_app_nid'],
'body' => $values['body'],
'title' => $values['title'],
);
}
/**
* Implementation of an Action. See Actions module.
*
* This action updates a user's profile FBML.
*/
function fb_actions_profile_fbml_form($values) {
$options = fb_get_app_options(TRUE);
$form['description'] = array('#value' => t('This action will update the current user\'s Facebook profile. Suitable for canvas pages and cron jobs (if infinite session is configured).'));
$form['fb_app_nid'] =
array('#type' => 'select',
'#title' => t('Application'),
'#default_value' => $values['fb_app_nid'],
'#options' => $options,
'#description' => t('Log into Facebook as which application? %current is OK when invoked from canvas pages or cron jobs.',
array('%current' => $options[FB_APP_CURRENT])),
);
$form['body'] = array('#type' => 'textarea',
'#title' => t('Profile FBML'),
'#default_value' => $values['body'],
'#description' => t('FBML to write to user\'s profile.<br />The following token will be replaced: !token_help',
array('!token_help' => theme('token_help', 'fb_app'))),
);
$form['body_filter'] = filter_form($values['body_filter'],
NULL,
array('body_filter'));
return $form;
}
function fb_actions_profile_fbml_validate($form_id, $values) {
// TODO
}
function fb_actions_profile_fbml_submit($form_id, $values) {
return array('fb_app_nid' => $values['fb_app_nid'],
'body' => $values['body'],
'body_filter' => $values['body_filter'],
);
}
function fb_actions_profile_fbml($values, &$object) {
//drupal_set_message("fb_actions_profile_fbml" . dpr($values, 1) . dpr($object, 1));
if ($values['hook'] == 'nodeapi') {
$node = $values['node'];
}
else if ($values['hook'] == 'comment') {
$comment = $values['comment'];
$node = node_load($comment->nid);
}
else if ($values['hook'] == 'user') {
$account = $values['user']; // untested
}
// 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);
}
if ($fb && $fb->get_loggedin_user()) {
fb_init_path($fb_app);
global $user;
$fbu = fb_get_fbu($user->uid, $fb_app);
// Replace fb_app related tokens
$body = token_replace($values['body'], 'fb_app', $fb_app);
$body = check_markup($body, $values['body_filter'], FALSE);
// Links in profile FBML must be fully-qualified. Here we attempt to
// replace relative links with fully qualified ones.
global $base_url, $base_path;
$patterns[] = '/"'.str_replace('/','\/', $base_path).'([^"]*)"/';
$replacements[] = '"'.$base_url.'/$1"';
$body = preg_replace($patterns, $replacements, $body);
// print("Setting facebook profile markup for $user->name to " . dpr($body, 1));
$fb->api_client->profile_setFBML($body, $fbu);
fb_report_errors($fb);
fb_init_path($fb_app, TRUE);
}
}
/**
* Implementation of an Action.
*
* This action updates reference FBML.
* http://developer.facebook.com/documentation.php?v=1.0&method=fbml.setRefHandle
*/
function fb_actions_ref_fbml_form($values) {
$form['description'] = array('#value' => t('This action will update reference FBML. See Facebook\'s documentation of the <fb:ref> tag. Suitable for canvas pages and cron jobs (if infinite session is configured).'));
$options = fb_get_app_options(TRUE);
$form['fb_app_nid'] =
array('#type' => 'select',
'#title' => t('Application'),
'#default_value' => $values['fb_app_nid'],
'#options' => $options,
'#description' => t('Log into Facebook as which application? %current is OK when invoked from canvas pages or cron jobs.',
array('%current' => $options[FB_APP_CURRENT])),
);
$form['handle'] = array('#type' => 'textfield',
'#title' => t('Handle'),
'#default_value' => $values['handle'],
);
$form['body'] = array('#type' => 'textarea',
'#title' => t('Profile FBML'),
'#default_value' => $values['body'],
'#description' => t('FBML to write to user\'s profile.<br />The following token will be replaced: !token_help',
array('!token_help' => theme('token_help', 'fb_app'))),
);
$form['body_filter'] = filter_form($values['body_filter'],
NULL,
array('body_filter'));
return $form;
}
function fb_actions_ref_fbml_validate($form_id, $values) {
// TODO
}
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
function fb_actions_ref_fbml_submit($form_id, $values) {
return array('handle' => $values['handle'],
'body' => $values['body'],
'body_filter' => $values['body_filter'],
);
}
function fb_actions_ref_fbml($values, &$object) {
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_init_path($fb_app);
// Replace fb_app related tokens
$body = token_replace($values['body'], 'fb_app', $fb_app);
$body = check_markup($body, $values['body_filter'], FALSE);
$fb->api_client->fbml_setRefHandle($values['handle'], $body);
fb_report_errors($fb);
fb_init_path($fb_app, TRUE); // Restore old paths
}
}
function fb_actions_cron_per_user_form($values) {
$form['description'] = array('#value' => t('This action will iterate through user\'s of a Facebook Application, attempt to log into the Facebook API as that user (or failing that, the infinite session user), and execute additional actions. Use this to perform per-user actions during a Facebook cron job.'));
$options = fb_get_app_options(FALSE);
$form['fb_app_nids'] =
array('#type' => 'select',
'#title' => t('Application'),
'#multiple' => TRUE,
'#required' => TRUE,
'#default_value' => $values['fb_app_nid'],
'#options' => $options,
'#description' => t('Perform these actions for each user of which applications?'),
);
foreach (actions_get_all_actions() as $aid => $action) {
$options[$action['type']][$aid] = $action['description'];
}
$form['actions'] = array('#type' => 'select',
'#title' => t('Actions'),
'#default_value' => $values['actions'],
'#multiple' => TRUE,
'#required' => TRUE,
'#options' => $options,
'#description' => t('Select one or more actions to perform while logged in as a Facebook Application user.'),
);
$form['throttle'] = array('#type' => 'textfield',
'#title' => t('Throttle'),
'#default_value' => $values['throttle'],
'#required' => TRUE,
'#description' => t('Number of users to iterate through each time this action is invoked. Recommended: start with a small number and increase when you are sure things are working.'),
);
return $form;
}
function fb_actions_cron_per_user_submit($form_id, $values) {
return array('fb_app_nids' => $values['fb_app_nids'],
'actions' => $values['actions'],
'throttle' => $values['throttle'],
);
}
function fb_actions_cron_per_user($values, $obj) {
foreach ($values['fb_app_nids'] as $nid) {
$fb_app = fb_get_app(array('nid' => $nid));
// Set paths as if on a canvas page.
fb_init_path($fb_app);
// perform per-user actions
// Save current settings
$before_fb = $GLOBALS['fb'];
$before_fb_app = $GLOBALS['fb_app'];
$before_user = $GLOBALS['user'];
// Find some users of the app, for whom cron has not run recently.
$result = db_query("SELECT * FROM {fb_user_app} WHERE apikey='%s' AND fbu > 0 AND added > 0 ORDER BY time_cron ASC LIMIT %d",
$fb_app->apikey,
$values['throttle']);
while ($data = db_fetch_object($result)) {
// Log into facebook as the user from the database
$account = fb_user_get_local_user($data->fbu, $fb_app);
if (!$account || !$account->uid) {
watchdog('fb cron', t('Facebook user %fbu does not correspond to a local account. Purging bad data from Facebook User table.',
array('%fbu' => $data->fbu)));
//db_query("DELETE FROM {fb_user_app} WHERE apikey='%s' AND fbu = %d",
// $fb_app->apikey,
// $data->fbu);
}
else {
// If here, local user has been found.
$fb = fb_api_init($fb_app, $data->fbu);
if (!$fb || !$fb->api_client->users_getLoggedInUser())
// Failed to log in as the current user, fallback to infinite session.
$fb = fb_api_init($fb_app, FB_FBU_INFINITE_SESSION);
if (!$fb || !$fb->api_client->users_getLoggedInUser()) {
watchdog('fb cron', t('Failed to log into %app during cron. Try testing infinite session key.',
array('%app' => $fb_app->title)));
}
else {
// if here, we're logged into facebook.
// Set things up as if this were a canvas page.
$GLOBALS['user'] = $account;
$GLOBALS['fb'] = $fb;
$GLOBALS['fb_app'] = $fb_app;
// Invoke any actions that we've been configured to invoke.
actions_do($values['actions'], $fb_app);
} // end if able to log into facebook
} // end if local user found.
// Record how recently cron was run for this user. We do this even if
// we failed to log in, because we don't want persistent problems to
// clog the cron queue. We'll get to this user again, eventually.
db_query("UPDATE {fb_user_app} SET time_cron=%d WHERE apikey='%s' AND fbu=%d",
time(), $fb_app->apikey, $data->fbu);
}
// Restore global variables
$GLOBALS['user'] = $before_user;
$GLOBALS['fb'] = $before_fb;
$GLOBALS['fb_app'] = $before_fb_app;
fb_init_path($fb_app, TRUE); // restore original path settings.
}
}
///////////////////////////////////////////////////////////////////
// Below this line is obsolete code. Actions have changed considerably, and the following is deprecated. Recommended that you get the very latest actions module and start using it.
Dave Cohen
committed
/**
* Implementation of an Action. See Actions module.
*
* This action publishes to a user's mini-feed.
*/
function action_fb_write_minifeed($op, $edit = array(), $node) {
if ($op == 'metadata') {
return array('description' => t('Post to Facebook mini-feed'),
'type' => t('Facebook'),
'batchable' => FALSE,
'configurable' => TRUE,
);
}
else if ($op == 'form') {
$options = fb_get_app_options(TRUE);
$form['description'] = array('#value' => t('Note that this action will only succeed when executed from a Facebook canvas page when the user is logged in, or on non-canvas pages when the logged in user has an infinite session key. These are privacy restrictions enforced by the Facebook API.'));
$form['fb_app_nid'] =
Dave Cohen
committed
array('#type' => 'select',
'#title' => t('Application'),
'#default_value' => $edit['fb_app_nid'],
Dave Cohen
committed
'#options' => $options,
'#description' => t('Log into Facebook as which action? If %current, action will only be performed only on canvas pages.',
array('%current' => $options[FB_APP_CURRENT])),
Dave Cohen
committed
);
$form['title'] = array('#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $edit['title'],
'#description' => t('Title line of mini-feed item. (Most Facebook mini-feed items have only a title, and no message body).'),
Dave Cohen
committed
'#required' => TRUE,
);
$form['body'] = array('#type' => 'textarea',
'#title' => t('Body'),
'#default_value' => $edit['body'],
'#description' => t('Text to publish on mini-feed. In many cases, only the title is required and this may be left blank.<br />The following token will be replaced: !token_help',
array('!token_help' => theme('token_help', 'node') . theme('token_help', 'fb_app'))),
);
return $form;
}
else if ($op == 'submit') {
return array('fb_app_nid' => $edit['fb_app_nid'],
Dave Cohen
committed
'body' => $edit['body'],
'title' => $edit['title'],
);
}
else if ($op == 'do') {
// Log into facebook as the current user.
if ($fb_app = $GLOBALS['fb_app'])
if ($edit['fb_app_nid'] == FB_APP_CURRENT || $fb_app->nid == $edit['fb_app_nid'])
Dave Cohen
committed
// We're in a canvas page for the desired app. We're already logged in.
$fb = $GLOBALS['fb'];
if (!$fb && $edit['fb_app_nid'] != FB_APP_CURRENT) {
Dave Cohen
committed
global $user;
// Need to log into this app.
$fb_app = fb_get_app(array('nid' => $edit['fb_app_nid']));
Dave Cohen
committed
$fbu = fb_get_fbu($user->uid, $fb_app);
if ($fbu) {
$fb = fb_api_init($fb_app, $fbu);
}
}
// Even if we have an $fb now, it may not have permission to do all things
// we ask of it.
if ($fb) {
// Replace both node and fb_app related tokens
$title = token_replace($edit['title'], 'node', $node);
$title = token_replace($title, 'fb_app', $fb_app);
$body = token_replace($edit['body'], 'node', $node);
$body = token_replace($body, 'fb_app', $fb_app);
$fb->api_client->feed_publishActionOfUser($title, $body);
fb_report_errors($fb);
}
}
}
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
/**
* Implementation of an Action. See Actions module.
*
* This action updates a user's profile FBML.
*/
function action_fb_set_profile_fbml($op, $edit = array(), $obj) {
if ($op == 'metadata') {
return array('description' => t('Facebook set profile FBML'),
'type' => t('Facebook'),
'batchable' => FALSE,
'configurable' => TRUE,
);
}
else if ($op == 'form') {
$options = fb_get_app_options(TRUE);
$form['description'] = array('#value' => t('This action will update the current user\'s Facebook profile. Suitable for canvas pages and cron jobs (if infinite session is configured).'));
$form['fb_app_nid'] =
array('#type' => 'select',
'#title' => t('Application'),
'#default_value' => $edit['fb_app_nid'],
'#options' => $options,
'#description' => t('Log into Facebook as which application? %current is OK when invoked from canvas pages or cron jobs.',
array('%current' => $options[FB_APP_CURRENT])),
);
$form['body'] = array('#type' => 'textarea',
'#title' => t('Profile FBML'),
'#default_value' => $edit['body'],
'#description' => t('FBML to write to user\'s profile.<br />The following token will be replaced: !token_help',
array('!token_help' => theme('token_help', 'fb_app'))),
);
return $form;
}
else if ($op == 'submit') {
return array('fb_app_nid' => $edit['fb_app_nid'],
'body' => $edit['body'],
);
}
else if ($op == 'do') {
// Log into facebook as the current user.
if ($fb_app = $GLOBALS['fb_app'])
if ($edit['fb_app_nid'] == FB_APP_CURRENT || $fb_app->nid == $edit['fb_app_nid'])
// We're in a canvas page for the desired app. We're already logged in.
$fb = $GLOBALS['fb'];
if (!$fb && $edit['fb_app_nid'] != FB_APP_CURRENT) {
// Need to log into this app.
$fb_app = fb_get_app(array('nid' => $edit['fb_app_nid']));
$fb = fb_api_init($fb_app, FB_FBU_INFINITE_SESSION);
}
if ($fb) {
global $user;
$fbu = fb_get_fbu($user->uid, $fb_app);
// Replace fb_app related tokens
$body = token_replace($edit['body'], 'fb_app', $fb_app);
// TODO: enable filters for body.
// print("Setting facebook profile markup for $user->name to " . dpr($body, 1));
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
$fb->api_client->profile_setFBML($body, $fbu);
fb_report_errors($fb);
}
}
}
/**
* Implementation of an Action.
*
* This action updates reference FBML.
* http://developer.facebook.com/documentation.php?v=1.0&method=fbml.setRefHandle
*/
function action_fb_set_ref_fbml($op, $edit = array(), $fb_app) {
if ($op == 'metadata') {
return array('description' => t('Facebook set reference FBML'),
'type' => t('Facebook App'),
'batchable' => FALSE,
'configurable' => TRUE,
);
}
else if ($op == 'form') {
$options = fb_get_app_options(TRUE);
$form['description'] = array('#value' => t('This action will update reference FBML. See Facebook\'s documentation of the <fb:ref> tag. Suitable for canvas pages and cron jobs (if infinite session is configured).'));
$form['handle'] = array('#type' => 'textfield',
'#title' => t('Handle'),
'#default_value' => $edit['handle'],
);
$form['body'] = array('#type' => 'textarea',
'#title' => t('Profile FBML'),
'#default_value' => $edit['body'],
'#description' => t('FBML to write to user\'s profile.<br />The following token will be replaced: !token_help',
array('!token_help' => theme('token_help', 'fb_app'))),
);
$form['body_filter'] = filter_form($edit['body_filter'],
NULL,
array('body_filter'));
return $form;
}
else if ($op == 'submit') {
return array('handle' => $edit['handle'],
'body' => $edit['body'],
'body_filter' => $edit['body_filter'],
);
}
else if ($op == 'do') {
if ($GLOBALS['fb_app']->apikey == $fb_app->apikey)
// Use global FB api, if set up.
$fb = $GLOBALS['fb'];
else
$fb = fb_api_init($fb_app, FB_FBU_INFINITE_SESSION);
// This will be set on canvas pages and Facebook App cron actions.
if ($fb) {
// Replace fb_app related tokens
$body = token_replace($edit['body'], 'fb_app', $fb_app);
$body = check_markup($body, $edit['body_filter'], FALSE);
$fb->api_client->fbml_setRefHandle($edit['handle'], $body);
// TODO: enable filters for body.
$fb->api_client->profile_setFBML($body, $fbu);
fb_report_errors($fb);
}
}
}