protected function SocialFacebookFormatter::renderComments in Open Social 7
Parse facebook comments response.
Parameters
array $items: JSON decoded string.
Return value
array Array with comments.
1 call to SocialFacebookFormatter::renderComments()
File
- includes/
social_comments.facebook.inc, line 181 - Facebook class
Class
- SocialFacebookFormatter
- @file Facebook class
Code
protected function renderComments($items) {
$comments = array();
if (isset($items['data'])) {
$items = $items['data'];
}
if (is_array($items)) {
if (!empty($this->max_items)) {
$items = array_slice($items, 0, $this->max_items);
}
foreach ($items as $item) {
$data = array();
// Get user data.
$user = !empty($item['from']) ? $item['from'] : NULL;
$userid = !empty($user['id']) ? check_plain($user['id']) : NULL;
$data['id'] = check_plain($item['id']);
$data['username'] = !empty($user['name']) ? check_plain($user['name']) : NULL;
$data['user_url'] = !empty($userid) ? url('https://www.facebook.com/' . $userid) : NULL;
$data['userphoto'] = !empty($userid) ? $this
->getUserPhoto($userid) : NULL;
$data['text'] = filter_xss($item['message']);
$data['timestamp'] = strtotime($item['created_time']);
$comments[] = $data;
}
}
return $comments;
}