function tweet_feed_process_tweets in Tweet Feed 7.3
Same name and namespace in other branches
- 6 tweet_feed.module \tweet_feed_process_tweets()
- 7 tweet_feed.module \tweet_feed_process_tweets()
- 7.2 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 570
Code
function tweet_feed_process_tweets($tweet_data, $feed, $number_to_get = 0, $run_count = 0, $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_str)
->execute();
if ($result
->rowCount() > 0) {
$tdata = $result
->fetchObject();
$hash = md5(serialize($tweet->full_text));
// If our hashes are equal, we have nothing to update and can move along
$update = $hash == $tdata->hash;
continue;
}
// 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 + $run_count * 100) . ' out of ' . $number_to_get . ' (' . number_format(($key + $run_count * 100) / $number_to_get * 100) . '%)', 'ok', $web_interface);
}
}
$tweets[] = $tweet;
}
return $tweets;
}