function twitter_puller::parse_items in Twitter Pull 7.2
Same name and namespace in other branches
- 6.2 twitter_pull.class.inc \twitter_puller::parse_items()
- 6 twitter_pull.class.inc \twitter_puller::parse_items()
- 7 twitter_pull.class.inc \twitter_puller::parse_items()
2 calls to twitter_puller::parse_items()
- twitter_puller::get_items in ./
twitter_pull.class.inc - twitter_puller::twitter_get_items in ./
twitter_pull.class.inc - Use the twitter module to get the results.
File
- ./
twitter_pull.class.inc, line 200 - 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();
// Convert arrays to objects.
$item = json_decode(json_encode($item), FALSE);
$twitter_user = $item->user;
if (variable_get('twitter_pull_retweet_user', TRUE) && !empty($item->retweeted_status)) {
$twitter_user = $item->retweeted_status->user;
}
// when importing lists $user is an array and not an object, secure $user as object.
$twitter_user = (object) $twitter_user;
$obj->id = check_plain($item->id_str);
// The name is the user's 'human-readable' name.
$obj->username = check_plain(!empty($twitter_user->name) ? $twitter_user->name : $item->from_user);
// The screen_name is the Twitter machine name, i.e., the string that is
// commonly seen with an '@' prefixed.
$obj->screenname = check_plain(!empty($twitter_user->screen_name) ? $twitter_user->screen_name : $item->from_user);
//retrieve the user photo
$obj->userphoto = check_plain(!empty($twitter_user->profile_image_url) ? $twitter_user->profile_image_url : $item->profile_image_url);
$obj->userphoto_https = check_plain(!empty($twitter_user->profile_image_url_https) ? $twitter_user->profile_image_url_https : $item->profile_image_url_https);
$obj->text = filter_xss($item->text);
//-- Convert date to unix timestamp so themer can easily work with it.
$obj->timestamp = strtotime($item->created_at);
$tweets[] = $obj;
}
}
$this->tweets = $tweets;
}