function twitter_puller::parse_items in Twitter Pull 6
Same name and namespace in other branches
- 6.2 twitter_pull.class.inc \twitter_puller::parse_items()
- 7.2 twitter_pull.class.inc \twitter_puller::parse_items()
- 7 twitter_pull.class.inc \twitter_puller::parse_items()
1 call to twitter_puller::parse_items()
File
- ./
twitter_pull.class.inc, line 83 - twitter pull class implementation
Class
- twitter_puller
- @file twitter pull class implementation
Code
function parse_items($items) {
$tweets = array();
//-- If search response then items are one level lower.
if (isset($items->results) && is_array($items->results)) {
$items = $items->results;
}
if (is_array($items)) {
$items = array_slice($items, 0, $this->num_items);
foreach ($items as $item) {
$obj = new stdClass();
$obj->id = check_plain($item->id_str);
$obj->username = isset($item->user) && !empty($item->user->screen_name) ? $item->user->screen_name : $item->from_user;
$obj->username = check_plain($obj->username);
$obj->userphoto = isset($item->user) && !empty($item->user->profile_image_url) ? $item->user->profile_image_url : $item->profile_image_url;
$obj->userphoto = check_plain($obj->userphoto);
$obj->text = filter_xss($item->text);
//-- Convert date to unix timestamp so themers can easily work with it.
//-- We need to suppress possible warnings (in PHP 5.3+) related to non-set timezones because
//-- Drupal6 does not save proper timezones (just offsets) and there's no good way to fix this.
$obj->timestamp = @strtotime($item->created_at);
$obj->time_ago = t('!time ago.', array(
'!time' => format_interval(time() - $obj->timestamp),
));
$tweets[] = $obj;
}
}
$this->tweets = $tweets;
}