Free Source Code – Twitter Display: get_new_tweet_count.php
Twitter Database Server
Twitter Display
Download
Install
Code Architecture
default.css
get_new_tweet_count.php
get_tweet_list.php
index.html
twitter_display.php
display_lib.php
site.js
tweet_list_template.txt
tweet_template.txt
twitter_display_config.php
This script is called by site.js to get the number of tweets in the database that have been added since the tweet list was displayed. The messages displayed along with the count are stored in twitter_display_config.php.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <?php /** * get_new_tweet_count.php * Return the count of new tweets as text/html * Latest copy of this code: http://140dev.com/free-twitter-api-source-code-library/ * @author Adam Green <140dev@gmail.com> * @license GNU Public License * @version BETA 0.30 */ require_once('twitter_display_config.php' ); require_once('../../db/140dev_config.php'); require_once('../../db/db_lib.php'); $oDB = new db; // This is called by site.js with an argument of first containing a tweet_id: // get_new_tweet_count.php?first=[tweet_id] // The count of any tweets with a higher tweet_id is returned // Fail if no first argument is received if (!isset($_GET['first'])) { return; } $query = 'SELECT tweet_id ' . 'FROM tweets ' . 'WHERE tweet_id > "' . $_GET['first'] . '"'; $result = $oDB->select($query); $new_tweet_count = mysqli_num_rows($result); if ($new_tweet_count==0) { print ''; } elseif ($new_tweet_count==1) { print NEW_TWEET_MESSAGE; } else { print $new_tweet_count . NEW_TWEETS_MESSAGE; } ?> |
streaming_framework