4 * This module still needs a lot of work, but is functional today.
5 * Please review this section if you upgrade because things will change.
6 * If you have issues upgrading, remove facebook from the addon list,
7 * view a page on your site, then add it back to the list. This will reset
8 * all of the plugin 'hooks'.
10 * 1. register an API key for your site from developer.facebook.com
11 * a. We'd be very happy if you include "Friendika" in the application name
12 * to increase name recognition. The Friendika icons are also present
13 * in the images directory and may be uploaded as a Facebook app icon.
14 * Use images/ff-16.jpg for the Icon and images/ff-128.jpg for the Logo.
15 * b. The url should be your site URL with a trailing slash.
16 * You may use http://portal.friendika.com/privacy as the privacy policy
17 * URL unless your site has different requirements, and
18 * http://portal.friendika.com as the Terms of Service URL unless
19 * you have different requirements. (Friendika is a software application
20 * and does not require Terms of Service, though your installation of it might).
21 * c. Set the following values in your .htconfig.php file
22 * $a->config['facebook']['appid'] = 'xxxxxxxxxxx';
23 * $a->config['facebook']['appsecret'] = 'xxxxxxxxxxxxxxx';
24 * Replace with the settings Facebook gives you.
25 * 2. Enable the facebook plugin by including it in .htconfig.php - e.g.
26 * $a->config['system']['addon'] = 'plugin1,plugin2,facebook';
27 * 3. Visit the Facebook Settings from "Settings->Plugin Settings" page.
28 * and click 'Install Facebook Connector'.
29 * 4. This will ask you to login to Facebook and grant permission to the
30 * plugin to do its stuff. Allow it to do so.
31 * 5. You're done. To turn it off visit your site's /facebook page again and
32 * 'Remove Facebook posting'.
34 * Turn logging on (see the github Friendika wiki page 'Settings') and
35 * repeat these steps if you have trouble.
36 * Vidoes and embeds will not be posted if there is no other content. Links
37 * and images will be converted to text and long posts truncated - with a link
38 * to view the full post. Posts with permission settings and comments will
39 * not be posted to Facebook.
43 define('FACEBOOK_MAXPOSTLEN', 420);
45 /* declare the facebook_module function so that /facebook url requests will land here */
47 function facebook_module() {}
51 /* If a->argv[1] is a nickname, this is a callback from Facebook oauth requests. */
53 function facebook_init(&$a) {
59 $r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
66 $auth_code = (($_GET['code']) ? $_GET['code'] : '');
67 $error = (($_GET['error_description']) ? $_GET['error_description'] : '');
71 logger('facebook_init: Error: ' . $error);
73 if($auth_code && $uid) {
75 $appid = get_config('facebook','appid');
76 $appsecret = get_config('facebook', 'appsecret');
78 $x = fetch_url('https://graph.facebook.com/oauth/access_token?client_id='
79 . $appid . '&client_secret=' . $appsecret . '&redirect_uri='
80 . urlencode($a->get_baseurl() . '/facebook/' . $nick)
81 . '&code=' . $auth_code);
83 logger('facebook_init: returned access token: ' . $x, LOGGER_DATA);
85 if(strpos($x,'access_token=') !== false) {
86 $token = str_replace('access_token=', '', $x);
87 if(strpos($token,'&') !== false)
88 $token = substr($token,0,strpos($token,'&'));
89 set_pconfig($uid,'facebook','access_token',$token);
90 set_pconfig($uid,'facebook','post','1');
97 // todo: is this a browser session or a server session? where do we go?
103 function fb_get_self($uid) {
104 $access_token = get_pconfig($uid,'facebook','access_token');
107 $s = fetch_url('https://graph.facebook.com/me/?access_token=' . $access_token);
109 $j = json_decode($s);
110 set_pconfig($uid,'facebook','self_id',(string) $j->id);
116 function fb_get_friends($uid) {
118 $access_token = get_pconfig($uid,'facebook','access_token');
121 $s = fetch_url('https://graph.facebook.com/me/friends?access_token=' . $access_token);
123 logger('facebook: fb_get_friends: ' . $s);
124 $j = json_decode($s);
125 logger('facebook: fb_get_friends: json: ' . print_r($j,true), LOGGER_DATA);
126 foreach($j->data as $person) {
127 $s = fetch_url('https://graph.facebook.com/' . $person->id . '?access_token=' . $access_token);
129 $jp = json_decode($s);
130 logger('fb_get_friends: info: ' . print_r($jp,true), LOGGER_DATA);
132 // always use numeric link for consistency
134 $jp->link = 'http://facebook.com/profile.php?id=' . $person->id;
136 // check if we already have a contact
138 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
148 // create contact record
149 $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `notify`, `poll`,
150 `name`, `nick`, `photo`, `network`, `rel`, `priority`,
151 `writable`, `blocked`, `readonly`, `pending` )
152 VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
154 dbesc(datetime_convert()),
159 dbesc('facebook ' . $jp->id),
161 dbesc(($jp->nickname) ? $jp->nickname : strtolower($jp->first_name)),
162 dbesc('https://graph.facebook.com/' . $jp->id . '/picture'),
163 dbesc(NETWORK_FACEBOOK),
170 $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
180 $contact_id = $r[0]['id'];
182 require_once("Photo.php");
184 $photos = import_profile_photo($r[0]['photo'],$uid,$contact_id);
186 $r = q("UPDATE `contact` SET `photo` = '%s',
192 WHERE `id` = %d LIMIT 1
197 dbesc(datetime_convert()),
198 dbesc(datetime_convert()),
199 dbesc(datetime_convert()),
209 function facebook_post(&$a) {
212 $value = ((x($_POST,'post_by_default')) ? intval($_POST['post_by_default']) : 0);
213 set_pconfig(local_user(),'facebook','post_by_default', $value);
218 function facebook_content(&$a) {
221 notice( t('Permission denied.') . EOL);
225 if($a->argc > 1 && $a->argv[1] === 'remove') {
226 del_pconfig(local_user(),'facebook','post');
227 notice( t('Facebook disabled') . EOL);
230 if($a->argc > 1 && $a->argv[1] === 'friends') {
231 fb_get_friends(local_user());
232 notice( t('Updating contacts') . EOL);
236 $fb_installed = get_pconfig(local_user(),'facebook','post');
238 $appid = get_config('facebook','appid');
241 notice( t('Facebook API key is missing.') . EOL);
245 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
246 . $a->get_baseurl() . '/addon/facebook/facebook.css' . '" media="all" />' . "\r\n";
248 $o .= '<h3>' . t('Facebook Connect') . '</h3>';
250 if(! $fb_installed) {
251 $o .= '<div id="facebook-enable-wrapper">';
253 $o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
254 . $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Install Facebook connector for this account.') . '</a>';
259 $o .= '<div id="facebook-disable-wrapper">';
261 $o .= '<a href="' . $a->get_baseurl() . '/facebook/remove' . '">' . t('Remove Facebook connector') . '</a></div>';
263 $o .= '<div id="facebook-post-default-form">';
264 $o .= '<form action="facebook" method="post" >';
265 $post_by_default = get_pconfig(local_user(),'facebook','post_by_default');
266 $checked = (($post_by_default) ? ' checked="checked" ' : '');
267 $o .= '<input type="checkbox" name="post_by_default" value="1"' . $checked . '/>' . ' ' . t('Post to Facebook by default') . '<br />';
268 $o .= '<input type="submit" name="submit" value="' . t('Submit') . '" /></form></div>';
274 function facebook_install() {
275 register_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook');
276 register_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets');
277 register_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings');
278 register_hook('cron', 'addon/facebook/facebook.php', 'facebook_cron');
282 function facebook_uninstall() {
283 unregister_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook');
284 unregister_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets');
285 unregister_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings');
286 unregister_hook('cron', 'addon/facebook/facebook.php', 'facebook_cron');
290 function facebook_cron($a,$b) {
292 $last = get_config('facebook','last_poll');
294 $poll_interval = get_config('facebook','poll_interval');
296 $poll_interval = 3600;
299 $next = $last + $poll_interval;
304 logger('facebook_cron');
306 set_config('facebook','last_poll', time());
308 $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'post' AND `v` = '1' ");
311 // check for new friends once a day
312 $last_friend_check = get_pconfig($rr['uid'],'facebook','friend_check');
313 if($last_friend_check)
314 $next_friend_check = $last_friend_check + 86400;
315 if($next_friend_check <= time()) {
316 fb_get_friends($rr['uid']);
317 set_pconfig($rr['uid'],'facebook','friend_check',time());
319 fb_consume_all($rr['uid']);
326 function facebook_plugin_settings(&$a,&$b) {
328 $b .= '<div class="settings-block">';
329 $b .= '<h3>' . t('Facebook') . '</h3>';
330 $b .= '<a href="facebook">' . t('Facebook Connector Settings') . '</a><br />';
335 function facebook_jot_nets(&$a,&$b) {
339 $fb_post = get_pconfig(local_user(),'facebook','post');
340 if(intval($fb_post) == 1) {
341 $fb_defpost = get_pconfig(local_user(),'facebook','post_by_default');
342 $selected = ((intval($fb_defpost) == 1) ? ' checked="checked" ' : '');
343 $b .= '<div class="profile-jot-net"><input type="checkbox" name="facebook_enable"' . $selected . 'value="1" /> '
344 . t('Post to Facebook') . '</div>';
349 function facebook_post_hook(&$a,&$b) {
352 * Post to Facebook stream
355 require_once('include/group.php');
357 logger('Facebook post');
362 if((local_user()) && (local_user() == $b['uid'])) {
365 $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
366 intval($b['parent']),
369 if(count($r) && substr($r[0]['uri'],0,4) === 'fb::')
370 $reply = substr($r[0]['uri'],4);
373 logger('facebook reply id=' . $reply);
376 if($b['private'] && $reply == false) {
377 $allow_people = expand_acl($b['allow_cid']);
378 $allow_groups = expand_groups(expand_acl($b['allow_gid']));
379 $deny_people = expand_acl($b['deny_cid']);
380 $deny_groups = expand_groups(expand_acl($b['deny_gid']));
382 $recipients = array_unique(array_merge($allow_people,$allow_groups));
383 $deny = array_unique(array_merge($deny_people,$deny_groups));
385 $allow_str = dbesc(implode(', ',$recipients));
387 $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $allow_str ) AND `network` = 'face'");
388 $allow_arr = array();
391 $allow_arr[] = $rr['notify'];
394 $deny_str = dbesc(implode(', ',$deny));
396 $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $deny_str ) AND `network` = 'face'");
400 $deny_arr[] = $rr['notify'];
403 if(count($deny_arr) && (! count($allow_arr))) {
405 // One or more FB folks were denied access but nobody on FB was specifically allowed access.
406 // This might cause the post to be open to public on Facebook, but only to selected members
407 // on another network. Since this could potentially leak a post to somebody who was denied,
408 // we will skip posting it to Facebook with a slightly vague but relevant message that will
409 // hopefully lead somebody to this code comment for a better explanation of what went wrong.
411 notice( t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL);
416 // if it's a private message but no Facebook members are allowed or denied, skip Facebook post
418 if((! count($allow_arr)) && (! count($deny_arr)))
422 if($b['verb'] == ACTIVITY_LIKE)
426 $appid = get_config('facebook', 'appid' );
427 $secret = get_config('facebook', 'appsecret' );
429 if($appid && $secret) {
431 logger('facebook: have appid+secret');
433 $fb_post = intval(get_pconfig(local_user(),'facebook','post'));
434 $fb_enable = (($fb_post && x($_POST,'facebook_enable')) ? intval($_POST['facebook_enable']) : 0);
435 $fb_token = get_pconfig(local_user(),'facebook','access_token');
437 logger('facebook: $fb_post: ' . $fb_post . ' $fb_enable: ' . $fb_enable . ' $fb_token: ' . $fb_token,LOGGER_DEBUG);
439 // post to facebook if it's a public post and we've ticked the 'post to Facebook' box,
440 // or it's a private message with facebook participants
441 // or it's a reply or likes action to an existing facebook post
443 if($fb_post && $fb_token && ($fb_enable || $b['private'] || $reply)) {
444 logger('facebook: able to post');
445 require_once('library/facebook.php');
446 require_once('include/bbcode.php');
450 logger('Facebook post: original msg=' . $msg, LOGGER_DATA);
452 // make links readable before we strip the code
454 if(preg_match("/\[url=(.+?)\](.+?)\[\/url\]/is",$msg,$matches)) {
457 if(substr($matches[2],0,5) != '[img]' )
458 $linkname = $matches[2];
461 $msg = preg_replace("/\[url=(.+?)\](.+?)\[\/url\]/is",'$2 $1',$msg);
463 if(preg_match("/\[img\](.+?)\[\/img\]/is",$msg,$matches))
464 $image = $matches[1];
466 $msg = preg_replace("/\[img\](.+?)\[\/img\]/is", t('Image: ') . '$1', $msg);
470 $msg = trim(strip_tags(bbcode($msg)));
471 $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
473 if (strlen($msg) > FACEBOOK_MAXPOSTLEN) {
475 require_once('library/slinky.php');
477 $display_url = $a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $b['id'];
478 $slinky = new Slinky( $display_url );
479 // setup a cascade of shortening services
480 // try to get a short link from these services
481 // in the order ur1.ca, trim, id.gd, tinyurl
482 $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) );
483 $shortlink = $slinky->short();
484 // the new message will be shortened such that "... $shortlink"
485 // will fit into the character limit
486 $msg = substr($msg, 0, FACEBOOK_MAXPOSTLEN - strlen($shortlink) - 4);
487 $msg .= '... ' . $shortlink;
492 logger('Facebook post: msg=' . $msg, LOGGER_DATA);
495 $postvars = array('access_token' => $fb_token);
499 'access_token' => $fb_token,
503 $postvars['picture'] = $image;
505 $postvars['link'] = $link;
507 $postvars['name'] = $linkname;
510 if(($b['private']) && (! $b['parent'])) {
511 $postvars['privacy'] = '{"value": "CUSTOM", "friends": "SOME_FRIENDS"';
512 if(count($allow_arr))
513 $postvars['privacy'] .= ',"allow": "' . implode(',',$allow_arr) . '"';
515 $postvars['privacy'] .= ',"deny": "' . implode(',',$deny_arr) . '"';
516 $postvars['privacy'] .= '}';
521 $url = 'https://graph.facebook.com/' . $reply . '/' . (($likes) ? 'likes' : 'comments');
524 $url = 'https://graph.facebook.com/me/feed';
526 $postvars['actions'] = '{"name": "' . t('View on Friendika') . '", "link": "' . $b['plink'] . '"}';
529 logger('facebook: post to ' . $url);
530 logger('facebook: postvars: ' . print_r($postvars,true));
532 // "test_mode" prevents anything from actually being posted.
533 // Otherwise, let's do it.
535 if(! get_config('facebook','test_mode'))
536 $x = post_url($url, $postvars);
538 $retj = json_decode($x);
540 q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1",
541 dbesc('fb::' . $retj->id),
546 logger('Facebook post returns: ' . $x, LOGGER_DEBUG);
554 function fb_consume_all($uid) {
556 require_once('include/items.php');
558 $access_token = get_pconfig($uid,'facebook','access_token');
561 $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
563 $j = json_decode($s);
564 logger('fb_consume_stream: wall: ' . print_r($j,true), LOGGER_DATA);
565 fb_consume_stream($uid,$j,true);
567 $s = fetch_url('https://graph.facebook.com/me/home?access_token=' . $access_token);
569 $j = json_decode($s);
570 logger('fb_consume_stream: feed: ' . print_r($j,true), LOGGER_DATA);
571 fb_consume_stream($uid,$j,false);
576 function fb_consume_stream($uid,$j,$wall = false) {
579 $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
583 $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1",
587 $my_local_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
590 $self_id = get_pconfig($uid,'facebook','self_id');
591 if(! count($j->data) || (! strlen($self_id)))
594 foreach($j->data as $entry) {
595 logger('fb_consume: entry: ' . print_r($entry,true), LOGGER_DATA);
598 $app = $entry->application;
599 if($app->id == get_config('facebook','appid') && $wall)
602 $r = q("SELECT * FROM `item` WHERE ( `uri` = '%s' OR `extid` = '%s') AND `uid` = %d LIMIT 1",
603 dbesc('fb::' . $entry->id),
604 dbesc('fb::' . $entry->id),
610 $top_item = $r[0]['id'];
613 $post_exists = false;
618 $datarray['gravity'] = 0;
619 $datarray['uid'] = $uid;
620 $datarray['wall'] = (($wall) ? 1 : 0);
621 $datarray['uri'] = $datarray['parent-uri'] = 'fb::' . $entry->id;
622 $from = $entry->from;
623 if($from->id == $self_id)
624 $datarray['contact-id'] = $self[0]['id'];
626 $r = q("SELECT * FROM `contact` WHERE `notify` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
631 $datarray['contact-id'] = $r[0]['id'];
634 // don't store post if we don't have a contact
636 if(! x($datarray,'contact-id'))
639 $datarray['verb'] = ACTIVITY_POST;
641 $datarray['owner-name'] = $self[0]['name'];
642 $datarray['owner-link'] = $self[0]['url'];
643 $datarray['owner-avatar'] = $self[0]['thumb'];
645 $datarray['author-name'] = $from->name;
646 $datarray['author-link'] = 'http://facebook.com/profile.php?id=' . $from->id;
647 $datarray['author-avatar'] = 'https://graph.facebook.com/' . $from->id . '/picture';
648 $datarray['plink'] = $datarray['author-link'] . '&v=wall&story_fbid=' . substr($entry->id,strpos($entry->id,'_') + 1);
650 $datarray['body'] = $entry->message;
652 $datarray['body'] .= "\n\n" . '[img]' . $entry->picture . '[/img]';
654 $datarray['body'] .= "\n" . linkify($entry->link);
656 $datarray['body'] .= "\n" . $entry->name;
658 $datarray['body'] .= "\n" . $entry->caption;
659 if($entry->description)
660 $datarray['body'] .= "\n" . $entry->description;
661 $datarray['created'] = datetime_convert('UTC','UTC',$entry->created_time);
662 $datarray['edited'] = datetime_convert('UTC','UTC',$entry->updated_time);
663 if($entry->privacy && $entry->privacy->value !== 'EVERYONE')
664 $datarray['private'] = 1;
665 $top_item = item_store($datarray);
666 $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
674 $likers = $entry->likes->data;
675 $comments = $entry->comments->data;
677 if(is_array($likers)) {
678 foreach($likers as $likes) {
680 $r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `verb` = '%s' AND `author-link` = '%s'
682 dbesc('fb::' . $entry->id),
684 dbesc(ACTIVITY_LIKE),
685 dbesc('http://facebook.com/profile.php?id=' . $likes->id)
691 $likedata['parent'] = $top_item;
692 $likedata['verb'] = ACTIVITY_LIKE;
695 $likedata['gravity'] = 3;
696 $likedata['uid'] = $uid;
697 $likedata['wall'] = (($wall) ? 1 : 0);
698 $likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
699 $likedata['parent-uri'] = 'fb::' . $entry->id;
700 if($likes->id == $self_id)
701 $likedata['contact-id'] = $self[0]['id'];
703 $r = q("SELECT * FROM `contact` WHERE `notify` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
708 $likedata['contact-id'] = $r[0]['id'];
710 if(! x($likedata,'contact-id'))
711 $likedata['contact-id'] = $orig_post['contact-id'];
713 $likedata['verb'] = ACTIVITY_LIKE;
714 $likedata['author-name'] = $likes->name;
715 $likedata['author-link'] = 'http://facebook.com/profile.php?id=' . $likes->id;
716 $likedata['author-avatar'] = 'https://graph.facebook.com/' . $likes->id . '/picture';
718 $author = '[url=' . $likedata['author-link'] . ']' . $likedata['author-name'] . '[/url]';
719 $objauthor = '[url=' . $orig_post['author-link'] . ']' . $orig_post['author-name'] . '[/url]';
720 $post_type = t('status');
721 $plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
722 $likedata['object-type'] = ACTIVITY_OBJ_NOTE;
724 $likedata['body'] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
725 $likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' .
726 '<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . $orig_post['plink'] . '">') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
728 $item = item_store($likedata);
731 if(is_array($comments)) {
732 foreach($comments as $cmnt) {
734 $r = q("SELECT * FROM `item` WHERE `uid` = %d AND ( `uri` = '%s' OR `extid` = '%s' ) LIMIT 1",
736 dbesc('fb::' . $cmnt->id),
737 dbesc('fb::' . $cmnt->id)
743 $cmntdata['parent'] = $top_item;
744 $cmntdata['verb'] = ACTIVITY_POST;
745 $cmntdata['gravity'] = 6;
746 $cmntdata['uid'] = $uid;
747 $cmntdata['wall'] = (($wall) ? 1 : 0);
748 $cmntdata['uri'] = 'fb::' . $cmnt->id;
749 $cmntdata['parent-uri'] = 'fb::' . $entry->id;
750 if($cmnt->from->id == $self_id) {
751 $cmntdata['contact-id'] = $self[0]['id'];
753 elseif(is_array($orig_post) && (x($orig_post,'contact-id')))
754 $cmntdata['contact-id'] = $orig_post['contact-id'];
756 $r = q("SELECT * FROM `contact` WHERE `notify` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
757 dbesc($cmnt->from->id),
761 $cmntdata['contact-id'] = $r[0]['id'];
763 if(! x($cmntdata,'contact-id'))
765 $cmntdata['created'] = datetime_convert('UTC','UTC',$cmnt->created_time);
766 $cmntdata['edited'] = datetime_convert('UTC','UTC',$cmnt->created_time);
767 $cmntdata['verb'] = ACTIVITY_POST;
768 $cmntdata['author-name'] = $cmnt->from->name;
769 $cmntdata['author-link'] = 'http://facebook.com/profile.php?id=' . $cmnt->from->id;
770 $cmntdata['author-avatar'] = 'https://graph.facebook.com/' . $cmnt->from->id . '/picture';
771 $cmntdata['body'] = $cmnt->message;
772 $item = item_store($cmntdata);