function tweet_feed_process_tweets in Tweet Feed 7.2
Same name and namespace in other branches
- 6 tweet_feed.module \tweet_feed_process_tweets()
- 7.3 tweet_feed.module \tweet_feed_process_tweets()
- 7 tweet_feed.module \tweet_feed_process_tweets()
Process each tweet
Iterate through our array of tweets and process them one at a time. This is designed for use with our drush command
1 call to tweet_feed_process_tweets()
- tweet_feed_pull_data_from_feed in ./
tweet_feed.module - Get Twitter Data
File
- ./
tweet_feed.module, line 483
Code
function tweet_feed_process_tweets($tweet_data, $feed, $web_interface = FALSE) {
$tweets = array();
$total_hashi = 0;
foreach ($tweet_data as $key => $tweet) {
// Initialize our update_node_id
$update_node_id = 0;
// find out if we already have this tweet, if we do, add the update primary key (pk)
$result = db_select('tweet_hashes', 'h')
->fields('h', array(
'nid',
'tid',
'hash',
))
->condition('h.tid', $tweet->id)
->execute();
if ($result
->rowCount() > 0) {
$tdata = $result
->fetchObject();
$hash = md5(serialize($tweet->text));
// If our hashes are equal, we have nothing to update and can move along
if ($hash == $tdata->hash) {
continue;
}
else {
$update_node_id = $tdata->nid;
}
}
// If we're using the web iterface, our batch processing will take care of tweet
// saving as well as progress counting. This is purely for drushes entertainment
if ($web_interface == FALSE) {
tweet_feed_save_tweet($tweet, $feed, $update_node_id, $tdata->hash);
if ($key > 1 && !($key % 20) || $key + 1 == count($tweet_data)) {
tweet_feed_set_message('Loaded ' . $key . ' out of ' . count($tweet_data) . ' (' . number_format($key / count($tweet_data) * 100, 2) . '%)', 'ok', $web_interface);
}
}
$tweets[] = $tweet;
}
return $tweets;
}