Changeset 736685
- Timestamp:
- 07/05/2013 01:51:22 PM (12 years ago)
- Location:
- tweet-watcher/trunk
- Files:
-
- 1 added
- 5 edited
-
class-tweet-watcher.php (modified) (3 diffs)
-
class-twitter-oauth.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
templates-admin/confirm-unauthenticate.php (added)
-
templates-admin/settings.php (modified) (1 diff)
-
tweet-watcher.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tweet-watcher/trunk/class-tweet-watcher.php
r603533 r736685 235 235 foreach ( $users as $user_id => & $user ) { 236 236 $args = array( 'include_entities' => 'true', 'count' => 100 ); 237 if ( isset( $user[ 'last_mention_id' ] ) ) {237 if ( isset( $user[ 'last_mention_id' ] ) && $user[ 'last_mention_id' ] ) { 238 238 $args[ 'since_id' ] = $user[ 'last_mention_id' ]; 239 239 } … … 241 241 $queued_mentions = (array) get_option( 'twtwchr_queued_mentions', array() ); 242 242 foreach ( $mentions as & $mention ) { 243 // error_log( "TW: Queue $mention->id_str" ); 243 244 array_unshift( $queued_mentions, $mention ); 244 245 } … … 259 260 foreach ( $users as $user_id => & $user ) { 260 261 $args = array( 'include_entities' => 'true', 'include_rts' => 'true', 'contributor_details' => 'true', 'count' => 100 ); 261 if ( isset( $user[ 'last_tweet_id' ] ) ) {262 if ( isset( $user[ 'last_tweet_id' ] ) && $user[ 'last_tweet_id' ] ) { 262 263 $args[ 'since_id' ] = $user[ 'last_tweet_id' ]; 263 264 } 264 if ( $ mentions = $this->oauth->get_tweets( $user_id, $args ) ) {265 if ( $tweets = $this->oauth->get_tweets( $user_id, $args ) ) { 265 266 $queued_tweets = (array) get_option( 'twtwchr_queued_tweets', array() ); 266 foreach ( $ mentions as & $mention) {267 array_unshift( $queued_tweets, $ mention);267 foreach ( $tweets as & $tweet ) { 268 array_unshift( $queued_tweets, $tweet ); 268 269 } 269 270 update_option( 'twtwchr_queued_tweets', $queued_tweets ); 270 $last_tweet = array_shift( $ mentions );271 $last_tweet = array_shift( $tweets ); 271 272 $this->oauth->set_user_property( $user_id, 'last_tweet_id', $last_tweet->id_str ); 272 273 } -
tweet-watcher/trunk/class-twitter-oauth.php
r601914 r736685 30 30 $params = array_merge( $params, $override_params ); 31 31 32 $response = $this->do_oauth( 'https://api.twitter.com/1 /statuses/mentions.json', 'GET', $params, $user[ 'oauth_token_secret' ] );32 $response = $this->do_oauth( 'https://api.twitter.com/1.1/statuses/mentions.json', 'GET', $params, $user[ 'oauth_token_secret' ] ); 33 33 return json_decode( wp_remote_retrieve_body( $response ) ); 34 34 } … … 51 51 $params = array_merge( $params, $override_params ); 52 52 53 $response = $this->do_oauth( 'https://api.twitter.com/1/statuses/user_timeline.json', 'GET', $params, $user[ 'oauth_token_secret' ] ); 53 $response = $this->do_oauth( 'https://api.twitter.com/1.1/statuses/user_timeline.json', 'GET', $params, $user[ 'oauth_token_secret' ] ); 54 return json_decode( wp_remote_retrieve_body( $response ) ); 55 } 56 57 function get_tweet_as_user( $user_id, $tweet_id_str, $override_params = array() ) { 58 // https://api.twitter.com/1/statuses/show.json?id=XXX 59 60 if ( ! $user = $this->get_user( $user_id ) ) 61 return new WP_Error( 'twtwchr_twitter_error', __( 'No user exists for that User ID. (Error 200)', 'twtwchr' ) ); 62 63 $params = array(); 64 $params['id'] = $tweet_id_str; 65 $params['user_id'] = $user_id; 66 $params['oauth_consumer_key'] = $this->oauth_consumer_key; 67 $params['oauth_nonce'] = $this->get_nonce(); 68 $params['oauth_signature_method'] = 'HMAC-SHA1'; 69 $params['oauth_timestamp'] = time() + $this->oauth_time_offset; 70 $params['oauth_token'] = $user[ 'oauth_token' ]; 71 $params['oauth_version'] = '1.0'; 72 73 $params = array_merge( $params, $override_params ); 74 75 $response = $this->do_oauth( 'https://api.twitter.com/1/statuses/show.json', 'GET', $params, $user[ 'oauth_token_secret' ] ); 54 76 return json_decode( wp_remote_retrieve_body( $response ) ); 55 77 } … … 235 257 if ( ! isset( $users[ $user_id ] ) ) 236 258 return false; 259 $user = & $users[ $user_id ][ 'last_tweet_id' ]; 237 260 return $users[ $user_id ]; 238 261 } 239 262 240 263 function get_users() { 241 return $this->get_property( 'users', array() ); 264 $users = $this->get_property( 'users', array() ); 265 foreach ( $users as & $user ) { 266 $user[ 'last_tweet_id' ] = isset( $user[ 'last_tweet_id' ] ) ? $user[ 'last_tweet_id' ] : null; 267 $user[ 'last_mention_id' ] = isset( $user[ 'last_mention_id' ] ) ? $user[ 'last_mention_id' ] : null; 268 } 269 return $users; 242 270 } 243 271 -
tweet-watcher/trunk/readme.txt
r603533 r736685 4 4 Requires at least: 3.4.2 5 5 Tested up to: 3.4.2 6 Stable tag: 0. 36 Stable tag: 0.6 7 7 8 8 A WordPress plugin which authenticates with a number of Twitter accounts and watches their mention and tweet stream, firing actions for each mention or tweet. … … 16 16 17 17 == Changelog == 18 19 = 0.6 = 20 21 Friday 05 July 2013 22 23 * BUGFIX: Don't set `since_id` if it's not available, as Twitter will object 24 * FIDDLING: Rename `$mention` to `$tweet` when talking about tweets not mentions 25 * BUGFIX: User Twitter API v1.1, so it actually works 26 27 = 0.5 = 28 29 Wednesday 5 December 2012 30 31 * BUGFIX: Removed some PHP notices from settings page for unset indexes on the $user array 32 * BUGFIX: Remove stray error_log call. 18 33 19 34 = 0.4 = -
tweet-watcher/trunk/templates-admin/settings.php
r603533 r736685 41 41 <?php endif; ?> 42 42 43 <p><a href="<?php echo esc_url( $auth_url ); ?>" class="button button-primary">Authenticate a new acc count</a></p>43 <p><a href="<?php echo esc_url( $auth_url ); ?>" class="button button-primary">Authenticate a new account</a></p> 44 44 45 45 </div> -
tweet-watcher/trunk/tweet-watcher.php
r603533 r736685 5 5 Plugin URI: https://github.com/simonwheatley/Tweet-Watcher/ 6 6 Description: Authenticates with a number of Twitter accounts and fires actions for each mention or tweet. 7 Version: 0. 47 Version: 0.6 8 8 Author: Simon Wheatley (Code for the People) 9 9 Author URI: http://codeforthepeople.com/ … … 42 42 return __FILE__; 43 43 } 44 45 ?>
Note: See TracChangeset
for help on using the changeset viewer.