4 * Description: Synchronizes the Facebook Newsfeed
6 * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
11 - B: Like für Kommentare senden
12 - B: Post auf Seite nicht als Seite
14 - C: Threading für Kommentare
15 - C: Posts von Seiten, die man nicht selber abonniert hat
16 - D: Like für Kommentare empfangen?
19 require_once("addon/fbpost/fbpost.php");
21 define('FBSYNC_DEFAULT_POLL_INTERVAL', 5); // given in minutes
23 function fbsync_install() {
24 register_hook('connector_settings', 'addon/fbsync/fbsync.php', 'fbsync_settings');
25 register_hook('connector_settings_post', 'addon/fbsync/fbsync.php', 'fbsync_settings_post');
26 register_hook('cron', 'addon/fbsync/fbsync.php', 'fbsync_cron');
29 function fbsync_uninstall() {
30 unregister_hook('connector_settings', 'addon/fbsync/fbsync.php', 'fbsync_settings');
31 unregister_hook('connector_settings_post', 'addon/fbsync/fbsync.php', 'fbsync_settings_post');
32 unregister_hook('cron', 'addon/fbsync/fbsync.php', 'fbsync_cron');
35 function fbsync_settings(&$a,&$s) {
40 /* Add our stylesheet to the page so we can make our settings look nice */
42 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/fbsync/fbsync.css' . '" media="all" />' . "\r\n";
44 /* Get the current state of our config variables */
46 $enabled = get_pconfig(local_user(),'fbsync','sync');
48 $checked = (($enabled) ? ' checked="checked" ' : '');
50 $def_enabled = get_pconfig(local_user(),'fbsync','create_user');
52 $def_checked = (($def_enabled) ? ' checked="checked" ' : '');
54 /* Add some HTML to the existing form */
56 $s .= '<div class="settings-block">';
57 $s .= '<h3>' . t('Facebook Import Settings') . '</h3>';
59 $s .= '<div id="fbsync-enable-wrapper">';
60 $s .= '<label id="fbsync-enable-label" for="fbsync-checkbox">' . t('Import Facebook newsfeed') . '</label>';
61 $s .= '<input id="fbsync-checkbox" type="checkbox" name="fbsync" value="1" ' . $checked . '/>';
62 $s .= '</div><div class="clear"></div>';
64 $s .= '<div id="fbsync-create_user-wrapper">';
65 $s .= '<label id="fbsync-create_user-label" for="fbsync-create_user">' . t('Automatically create contacts') . '</label>';
66 $s .= '<input id="fbsync-create_user" type="checkbox" name="create_user" value="1" ' . $def_checked . '/>';
67 $s .= '</div><div class="clear"></div>';
69 /* provide a submit button */
71 $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="fbsync-submit" name="fbsync-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
75 function fbsync_settings_post(&$a,&$b) {
77 if(x($_POST,'fbsync-submit')) {
78 set_pconfig(local_user(),'fbsync','sync',intval($_POST['fbsync']));
79 set_pconfig(local_user(),'fbsync','create_user',intval($_POST['create_user']));
83 function fbsync_cron($a,$b) {
84 $last = get_config('fbsync','last_poll');
86 $poll_interval = intval(get_config('fbsync','poll_interval'));
88 $poll_interval = FBSYNC_DEFAULT_POLL_INTERVAL;
91 $next = $last + ($poll_interval * 60);
93 logger('fbsync_cron: poll intervall not reached');
97 logger('fbsync_cron: cron_start');
99 $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'fbsync' AND `k` = 'sync' AND `v` = '1' ORDER BY RAND()");
102 fbsync_get_self($rr['uid']);
104 logger('fbsync_cron: importing timeline from user '.$rr['uid']);
105 fbsync_fetchfeed($a, $rr['uid']);
109 logger('fbsync: cron_end');
111 set_config('fbsync','last_poll', time());
114 function fbsync_createpostarray($a, $uid, $self, $contacts, $applications, $post) {
116 $postarray = array();
117 $postarray['gravity'] = 0;
118 $postarray['uid'] = $uid;
119 $postarray['wall'] = 0;
121 $postarray['verb'] = ACTIVITY_POST;
123 $postarray['uri'] = "fb::".$post->post_id;
124 $postarray['thr-parent'] = $postarray['uri'];
125 $postarray['parent-uri'] = $postarray['uri'];
126 $postarray['plink'] = $post->permalink;
128 $contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], true);
132 elseif ($contact_id == 0)
133 $contact_id = $self[0]["id"];
135 $postarray['contact-id'] = $contact_id;
137 $postarray['owner-name'] = $contacts[$post->source_id]->name;
138 $postarray['owner-link'] = $contacts[$post->source_id]->url;
139 $postarray['owner-avatar'] = $contacts[$post->source_id]->pic_square;
141 $postarray['author-name'] = $contacts[$post->actor_id]->name;
142 $postarray['author-link'] = $contacts[$post->actor_id]->url;
143 $postarray['author-avatar'] = $contacts[$post->actor_id]->pic_square;
145 $postarray["body"] = (isset($post->message) ? escape_tags($post->message) : '');
147 $msgdata = fbsync_convertmsg($a, $postarray["body"]);
149 $postarray["body"] = $msgdata["body"];
150 $postarray["tag"] = $msgdata["tags"];
152 if(isset($post->attachment->name) and isset($post->attachment->href))
153 $postarray["body"] .= "\n\n[bookmark=".$post->attachment->href."]".$post->attachment->name."[/bookmark]";
154 elseif (isset($post->attachment->name) AND ($post->attachment->name != ""))
155 $postarray["body"] .= "\n\n[b]" . $post->attachment->name."[/b]";
158 if(isset($post->attachment->description) and ($post->attachment->fb_object_type != "photo"))
159 $quote = $post->attachment->description;
161 if(isset($post->attachment->caption) and ($post->attachment->fb_object_type == "photo"))
162 $quote = $post->attachment->caption;
164 if (isset($post->attachment->media) AND !strstr($post->attachment->href, "://www.youtube.com/")
165 AND !strstr($post->attachment->href, "://youtu.be/")
166 AND !strstr($post->attachment->href, ".vimeo.com/")) {
167 foreach ($post->attachment->media AS $media) {
168 //$media->photo->owner = number_format($media->photo->owner, 0, '', '');
169 //if ($media->photo->owner != '') {
170 // $postarray['author-name'] = $contacts[$media->photo->owner]->name;
171 // $postarray['author-link'] = $contacts[$media->photo->owner]->url;
172 // $postarray['author-avatar'] = $contacts[$media->photo->owner]->pic_square;
175 if(isset($media->src) && isset($media->href))
176 $postarray["body"] .= "\n".'[url='.$media->href.'][img]'.fpost_cleanpicture($media->src).'[/img][/url]';
178 if (isset($media->src))
179 $postarray["body"] .= "\n".'[img]'.fpost_cleanpicture($media->src).'[/img]';
181 // if just a link, it may be a wall photo - check
182 if(isset($post->link))
183 $postarray["body"] .= fbpost_get_photo($media->href);
189 $postarray["body"] .= "\n[quote]".$quote."[/quote]";
191 $postarray["body"] = trim($postarray["body"]);
193 $postarray['created'] = datetime_convert('UTC','UTC',date("c", $post->created_time));
194 $postarray['edited'] = datetime_convert('UTC','UTC',date("c", $post->updated_time));
196 $postarray['app'] = $applications[$post->app_id]->display_name;
198 if ($postarray['app'] == "")
199 $postarray['app'] = "Facebook";
201 if(isset($post->privacy) && $post->privacy->value !== '') {
202 $postarray['private'] = 1;
203 $postarray['allow_cid'] = '<' . $self[0]['id'] . '>';
207 $postarray["location"] = $post->place->name;
208 postarray["coord"] = $post->geo->coordinates[0]." ".$post->geo->coordinates[1];
214 function fbsync_createcommentpostarray($a, $uid, $self_id, $self, $user, $contacts, $applications, $comment) {
216 // check if it was already imported
217 $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
219 dbesc('fb::'.$comment->id)
224 // check if it was an own post (separate posting for performance reasons)
225 $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `extid` = '%s' LIMIT 1",
227 dbesc('fb::'.$comment->id)
232 $postarray = array();
233 $postarray['gravity'] = 0;
234 $postarray['uid'] = $uid;
235 $postarray['wall'] = 0;
237 $postarray['verb'] = ACTIVITY_POST;
239 $postarray['uri'] = "fb::".$comment->id;
240 $postarray['thr-parent'] = "fb::".$comment->post_id;
241 $postarray['parent-uri'] = "fb::".$comment->post_id;
242 //$postarray['plink'] = $comment->permalink;
244 $contact_id = fbsync_fetch_contact($uid, $contacts[$comment->fromid], array(), false);
246 if ($contact_id <= 0)
247 $contact_id = $self[0]["id"];
249 if ($comment->fromid != $self_id) {
250 $postarray['contact-id'] = $contact_id;
251 $postarray['owner-name'] = $contacts[$comment->fromid]->name;
252 $postarray['owner-link'] = $contacts[$comment->fromid]->url;
253 $postarray['owner-avatar'] = $contacts[$comment->fromid]->pic_square;
255 $postarray['contact-id'] = $self[0]["id"];
256 $postarray['owner-name'] = $self[0]["name"];
257 $postarray['owner-link'] = $self[0]["url"];
258 $postarray['owner-avatar'] = $self[0]["photo"];
261 $postarray['author-name'] = $postarray['owner-name'];
262 $postarray['author-link'] = $postarray['owner-link'];
263 $postarray['author-avatar'] = $postarray['owner-avatar'];
265 $msgdata = fbsync_convertmsg($a, $comment->text);
267 $postarray["body"] = $msgdata["body"];
268 $postarray["tag"] = $msgdata["tags"];
270 $postarray['created'] = datetime_convert('UTC','UTC',date("c", $comment->time));
271 $postarray['edited'] = datetime_convert('UTC','UTC',date("c", $comment->time));
273 $postarray['app'] = $applications[$comment->app_id]->display_name;
275 if ($postarray['app'] == "")
276 $postarray['app'] = "Facebook";
278 $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
279 dbesc($postarray['parent-uri']),
284 $importer_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
286 $own_contact = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
287 intval($uid), dbesc("facebook::".$self_id));
289 if (!count($own_contact))
292 foreach($myconv as $conv) {
294 // now if we find a match, it means we're in this conversation
295 if(!link_compare($conv['author-link'],$importer_url) AND !link_compare($conv['author-link'],$own_contact[0]["url"]))
298 // Fetching the item number
299 $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
301 dbesc('fb::'.$comment->post_id)
308 require_once('include/enotify.php');
310 $conv_parent = $conv['parent'];
313 'type' => NOTIFY_COMMENT,
314 'notify_flags' => $user[0]['notify-flags'],
315 'language' => $user[0]['language'],
316 'to_name' => $user[0]['username'],
317 'to_email' => $user[0]['email'],
318 'uid' => $user[0]['uid'],
319 'item' => $postarray,
320 'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $item,
321 'source_name' => $postarray['author-name'],
322 'source_link' => $postarray['author-link'],
323 'source_photo' => $postarray['author-avatar'],
324 'verb' => ACTIVITY_POST,
326 'parent' => $conv_parent,
329 notification($notifyarr);
331 // only send one notification
339 function fbsync_createlikepostarray($a, $uid, $self_id, $self, $contacts, $like) {
341 $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
342 dbesc("fb::".$like->post_id),
349 return(array("uri"=>""));
351 // If we posted the like locally, it will be found with our url, not the FB url.
353 $second_url = (($like->user_id == $self_id) ? $self[0]["url"] : $contacts[$like->user_id]->url);
355 $r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `verb` = '%s'
356 AND (`author-link` = '%s' OR `author-link` = '%s') LIMIT 1",
357 dbesc($orig_post["uri"]),
359 dbesc(ACTIVITY_LIKE),
360 dbesc($contacts[$like->user_id]->url),
367 $contact_id = fbsync_fetch_contact($uid, $contacts[$like->user_id], array(), false);
369 if ($contact_id <= 0)
370 $contact_id = $self[0]["id"];
373 $likedata['parent'] = $orig_post['id'];
374 $likedata['verb'] = ACTIVITY_LIKE;
375 $likedata['gravity'] = 3;
376 $likedata['uid'] = $uid;
377 $likedata['wall'] = 0;
378 $likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
379 $likedata['parent-uri'] = $orig_post["uri"];
380 $likedata['app'] = "Facebook";
381 $likedata['verb'] = ACTIVITY_LIKE;
383 if ($like->user_id != $self_id) {
384 $likedata['contact-id'] = $contact_id;
385 $likedata['author-name'] = $contacts[$like->user_id]->name;
386 $likedata['author-link'] = $contacts[$like->user_id]->url;
387 $likedata['author-avatar'] = $contacts[$like->user_id]->pic_square;
389 $likedata['contact-id'] = $self[0]["id"];
390 $likedata['author-name'] = $self[0]["name"];
391 $likedata['author-link'] = $self[0]["url"];
392 $likedata['author-avatar'] = $self[0]["photo"];
395 $author = '[url=' . $likedata['author-link'] . ']' . $likedata['author-name'] . '[/url]';
397 $objauthor = '[url=' . $orig_post['author-link'] . ']' . $orig_post['author-name'] . '[/url]';
398 $post_type = t('status');
400 $plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
401 $likedata['object-type'] = ACTIVITY_OBJ_NOTE;
403 $likedata['body'] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
405 $likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' .
406 '<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . xmlify($orig_post['plink']) . '" />') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
409 $r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `author-link` = '%s' AND `verb` = '%s' AND `uid` = %d LIMIT 1",
410 dbesc($likedata['parent-uri']),
411 dbesc($likedata['author-link']),
412 dbesc(ACTIVITY_LIKE),
417 return(array("uri"=>""));
422 function fbsync_fetch_contact($uid, $contact, $create_user) {
424 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
425 intval($uid), dbesc("facebook::".$contact->id));
427 if(!count($r) AND !$create_user)
430 if (count($r) AND ($r[0]["readonly"] OR $r[0]["blocked"])) {
431 logger("fbsync_fetch_contact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
435 $avatarpicture = $contact->pic_square;
438 // create contact record
439 q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
440 `name`, `nick`, `photo`, `network`, `rel`, `priority`,
441 `writable`, `blocked`, `readonly`, `pending`)
442 VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0)",
444 dbesc(datetime_convert()),
445 dbesc($contact->url),
446 dbesc(normalise_link($contact->url)),
447 dbesc($contact->username."@facebook.com"),
448 dbesc("facebook::".$contact->id),
450 dbesc("facebook::".$contact->id),
451 dbesc($contact->name),
452 dbesc($contact->username),
453 dbesc($avatarpicture),
454 dbesc(NETWORK_FACEBOOK),
455 intval(CONTACT_IS_FRIEND),
460 $r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
461 dbesc("facebook::".$contact->id),
468 $contact_id = $r[0]['id'];
470 $g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
474 if($g && intval($g[0]['def_gid'])) {
475 require_once('include/group.php');
476 group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
479 require_once("Photo.php");
481 $photos = import_profile_photo($avatarpicture,$uid,$contact_id);
483 q("UPDATE `contact` SET `photo` = '%s',
493 dbesc(datetime_convert()),
494 dbesc(datetime_convert()),
495 dbesc(datetime_convert()),
499 // update profile photos once every 12 hours as we have no notification of when they change.
500 $update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
502 // check that we have all the photos, this has been known to fail on occasion
503 if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
505 logger("fbsync_fetch_contact: Updating contact ".$contact->username, LOGGER_DEBUG);
507 require_once("Photo.php");
509 $photos = import_profile_photo($avatarpicture, $uid, $r[0]['id']);
511 q("UPDATE `contact` SET `photo` = '%s',
516 `avatar-date` = '%s',
526 dbesc(datetime_convert()),
527 dbesc(datetime_convert()),
528 dbesc(datetime_convert()),
529 dbesc($contact->url),
530 dbesc(normalise_link($contact->url)),
531 dbesc($contact->username."@facebook.com"),
532 dbesc($contact->name),
533 dbesc($contact->username),
541 function fbsync_get_self($uid) {
542 $access_token = get_pconfig($uid,'facebook','access_token');
545 $s = fetch_url('https://graph.facebook.com/me/?access_token=' . $access_token);
547 $j = json_decode($s);
548 set_pconfig($uid,'fbsync','self_id',(string) $j->id);
552 function fbsync_convertmsg($a, $body) {
555 $tags = get_tags($body);
558 foreach($tags as $tag) {
559 if (strstr(trim($tag), " "))
562 if(strpos($tag,'#') === 0) {
563 if(strpos($tag,'[url='))
566 // don't link tags that are already embedded in links
568 if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
570 if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
573 $basetag = str_replace('_',' ',substr($tag,1));
574 $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
575 if(strlen($str_tags))
577 $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
579 } elseif(strpos($tag,'@') === 0) {
580 $basetag = substr($tag,1);
581 $body = str_replace($tag,'@[url=https://twitter.com/' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
587 $cnt = preg_match_all('/@\[url=(.*?)\[\/url\]/ism',$body,$matches,PREG_SET_ORDER);
589 foreach($matches as $mtch) {
590 if(strlen($str_tags))
592 $str_tags .= '@[url=' . $mtch[1] . '[/url]';
596 return(array("body"=>$body, "tags"=>$str_tags));
600 function fbsync_fetchfeed($a, $uid) {
601 $access_token = get_pconfig($uid,'facebook','access_token');
602 $last_updated = get_pconfig($uid,'fbsync','last_updated');
603 $self_id = get_pconfig($uid,'fbsync','self_id');
605 $create_user = get_pconfig($uid, 'fbsybc', 'create_user');
606 $do_likes = get_config('fbsync', 'do_likes');
608 $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
612 $user = q("SELECT * FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1",
618 require_once('include/items.php');
620 if ($last_updated == "")
623 logger("fbsync_fetchfeed: fetching content for user ".$self_id);
626 "posts" => "SELECT action_links, actor_id, app_data, app_id, attachment, attribution, comment_info, created_time, filter_key, like_info, message, message_tags, parent_post_id, permalink, place, post_id, privacy, share_count, share_info, source_id, subscribed, tagged_ids, type, updated_time, with_tags FROM stream where filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND updated_time > $last_updated ORDER BY created_time DESC",
627 "comments" => "SELECT app_id, attachment, post_id, id, likes, fromid, time, text, text_tags, user_likes, likes FROM comment WHERE post_id IN (SELECT post_id FROM #posts) order by time desc",
628 "profiles" => "SELECT id, name, username, url, pic_square FROM profile WHERE id IN (SELECT actor_id FROM #posts) OR id IN (SELECT fromid FROM #comments) OR id IN (SELECT source_id FROM #posts)",
629 "applications" => "SELECT app_id, display_name FROM application WHERE app_id IN (SELECT app_id FROM #posts) OR app_id IN (SELECT app_id FROM #comments)",
630 "avatars" => "SELECT id, real_size, size, url FROM square_profile_pic WHERE id IN (SELECT id FROM #profiles) AND size = 256");
633 $fql["likes"] = "SELECT post_id, user_id FROM like WHERE post_id IN (SELECT post_id FROM #posts)";
634 $fql["profiles"] .= " OR id IN (SELECT user_id FROM #likes)";
637 $url = "https://graph.facebook.com/fql?q=".urlencode(json_encode($fql))."&access_token=".$access_token;
639 $feed = fetch_url($url);
641 $data = json_decode($feed);
647 $applications = array();
650 foreach($data->data AS $query) {
651 switch ($query->name) {
653 $posts = array_reverse($query->fql_result_set);
656 $comments = $query->fql_result_set;
659 $likes = $query->fql_result_set;
662 $profiles = $query->fql_result_set;
665 $applications = $query->fql_result_set;
668 $avatars = $query->fql_result_set;
673 $square_avatars = array();
675 $application_data = array();
676 $post_data = array();
677 $comment_data = array();
679 foreach ($avatars AS $avatar) {
680 $avatar->id = number_format($avatar->id, 0, '', '');
681 $square_avatars[$avatar->id] = $avatar;
685 foreach ($profiles AS $profile) {
686 $profile->id = number_format($profile->id, 0, '', '');
688 if ($square_avatars[$profile->id]->url != "")
689 $profile->pic_square = $square_avatars[$profile->id]->url;
691 $contacts[$profile->id] = $profile;
694 unset($square_avatars);
696 foreach ($applications AS $application) {
697 $application->app_id = number_format($application->app_id, 0, '', '');
698 $application_data[$application->app_id] = $application;
700 unset($applications);
702 foreach ($posts AS $post) {
703 $post->actor_id = number_format($post->actor_id, 0, '', '');
704 $post->source_id = number_format($post->source_id, 0, '', '');
705 $post->app_id = number_format($post->app_id, 0, '', '');
706 $post_data[$post->post_id] = $post;
710 foreach($comments AS $comment) {
711 $comment->fromid = number_format($comment->fromid, 0, '', '');
712 $comment_data[$comment->id] = $comment;
716 foreach ($post_data AS $post) {
718 if ($post->updated_time > $last_updated)
719 $last_updated = $post->updated_time;
721 $postarray = fbsync_createpostarray($a, $uid, $self, $contacts, $application_data, $post);
722 //print_r($postarray);
723 if (trim($postarray["body"]) != "") {
724 $item = item_store($postarray);
725 logger('fbsync_fetchfeed: User '.$self[0]["nick"].' posted feed item '.$item, LOGGER_DEBUG);
729 foreach ($comment_data AS $comment) {
730 $postarray = fbsync_createcommentpostarray($a, $uid, $self_id, $self, $user, $contacts, $application_data, $comment);
732 if (trim($postarray["body"]) != "") {
733 $item = item_store($postarray);
734 logger('fbsync_fetchfeed: User '.$self[0]["nick"].' posted comment '.$item, LOGGER_DEBUG);
738 foreach($likes AS $like) {
739 $like->user_id = number_format($like->user_id, 0, '', '');
741 $postarray = fbsync_createlikepostarray($a, $uid, $self_id, $self, $contacts, $like);
743 if ($postarray["uri"] != "") {
744 $item = item_store($postarray);
745 logger('fbsync_fetchfeed: User '.$self[0]["nick"].' liked '.$item, LOGGER_DEBUG);
750 set_pconfig($uid,'fbsync','last_updated', $last_updated);