Changeset 729135
- Timestamp:
- 06/21/2013 01:15:04 AM (13 years ago)
- Location:
- evergreen-post-tweeter/trunk
- Files:
-
- 5 edited
-
Include/ept-oauth.php (modified) (4 diffs)
-
ept-admin.php (modified) (7 diffs)
-
ept-core.php (modified) (4 diffs)
-
evergreen.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
evergreen-post-tweeter/trunk/Include/ept-oauth.php
r725789 r729135 222 222 } 223 223 224 function do_get_request_oauth($url, $oauth_header) 225 { 226 EPT_DEBUG('Doing GET request, OAUTH header is ' . $oauth_header); 227 $request = new WP_Http; 228 EPT_DEBUG('..using WP transport'); 229 230 $params['method'] = 'GET'; 231 $params['headers'] = array('Authorization' => $oauth_header); 232 233 $result = $request->request($url, $params); 234 235 if (!is_wp_error($result)) { 236 237 EPT_DEBUG('..WP transport returned a status code of ' . $result['response']['code']); 238 239 $this->response_code = $result['response']['code']; 240 241 if ($result['response']['code'] == '200') { 242 return $result['body']; 243 } else { 244 EPT_DEBUG('..RESPONSE was ' . print_r($result['response'], true)); 245 246 switch ($result['response']['code']) { 247 case 403: 248 $this->duplicate_tweet = true; 249 break; 250 } 251 252 $error_message_found = preg_match('#<error>(.*)</error>#i', $result['body'], $matches); 253 if ($error_message_found) { 254 $this->error_message = $matches[1]; 255 } 256 return $result; 257 } 258 } else { 259 EPT_DEBUG("..WP transport returned an error, " . $result->get_error_message()); 260 } 261 } 262 224 263 function get_nonce() { 225 264 return md5(mt_rand() + mt_rand()); … … 263 302 } 264 303 265 function do_oauth($url, $params, $token_secret = '') { 266 $sig_string = $this->create_signature_base_string(false, $url, $params); 267 304 function do_oauth($url, $params, $token_secret = '', $method = 'post') { 305 if ($method == 'post') { 306 $sig_string = $this->create_signature_base_string(false, $url, $params); 307 } else if ($method == 'get') { 308 $sig_string = $this->create_signature_base_string(true, 'https://api.twitter.com/1.1/users/show.json', $params); 309 } 268 310 //$hash = hash_hmac( 'sha1', $sig_string, EPT_OAUTH_CONSUMER_SECRET . '&' . $token_secret, true ); 269 311 $hash = $this->hmac_sha1($this->oauth_consumer_secret . '&' . $token_secret, $sig_string); … … 285 327 286 328 $header .= implode($all_params, ", "); 287 288 return $this->do_request($url, $header, $other_params); 329 if ($method == 'post') { 330 return $this->do_request($url, $header, $other_params); 331 } else { 332 return $this->do_get_request_oauth($url, $header); 333 } 289 334 } 290 335 … … 376 421 return EPT_OAUTH_AUTHORIZE_URL . '?oauth_token=' . $token; 377 422 } 378 379 function get_user_info($user_id) { 380 $url = 'https://api.twitter.com/1.1/users/show.json?user_id=' . $user_id; 381 382 $result = $this->do_get_request($url); 423 // making new user info 424 function get_user_info($screen_name, $token, $token_secret) { 425 $params = array(); 426 427 $params['oauth_consumer_key'] =$this->oauth_consumer_key; 428 $params['oauth_signature_method'] = 'HMAC-SHA1'; 429 $params['oauth_timestamp'] = time() + $this->oauth_time_offset; 430 $params['oauth_nonce'] = $this->get_nonce(); 431 $params['oauth_version'] = '1.0'; 432 $params['oauth_token'] = $token; 433 $params['screen_name'] = $screen_name; 434 435 $url = 'https://api.twitter.com/1.1/users/show.json?screen_name=' . $screen_name; 436 437 $result = $this->do_oauth($url, $params, $token_secret, 'get'); 383 438 if ($result) { 384 439 $new_params = json_decode($result, true); 385 440 return $new_params; 441 } else { 442 return $result; 386 443 } 387 444 } -
evergreen-post-tweeter/trunk/ept-admin.php
r725789 r729135 27 27 $settings['oauth_access_token_secret'] = $result['oauth_token_secret']; 28 28 $settings['user_id'] = $result['user_id']; 29 30 $result = $ept_oauth->get_user_info($result['user_id']); 29 $settings['screen_name'] = $result['screen_name']; 30 31 $result = $ept_oauth->get_user_info($result['screen_name'], $settings['oauth_access_token'], $settings['oauth_access_token_secret']); 31 32 if ($result) { 32 $settings['profile_image_url'] = $result[' user']['profile_image_url'];33 $settings['screen_name'] = $result[' user']['screen_name'];34 if (isset($result[' user']['location'])) {35 $settings['location'] = $result[' user']['location'];33 $settings['profile_image_url'] = $result['profile_image_url']; 34 $settings['screen_name'] = $result['screen_name']; 35 if (isset($result['location'])) { 36 $settings['location'] = $result['location']; 36 37 } else { 37 38 $settings['location'] = false; 38 39 } 39 40 } 40 41 41 42 ept_save_settings($settings); 42 43 echo '<script language="javascript">window.open ("' . get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=Evergreen","_self")</script>'; … … 170 171 update_option('ept_opt_use_url_shortner', true); 171 172 } else { 172 173 173 update_option('ept_opt_use_url_shortner', false); 174 174 } … … 261 261 } 262 262 263 //use Pause Tweet? 264 if (isset($_POST['ept_opt_use_pause_tweet'])) { 265 update_option('ept_opt_use_pause_tweet', true); 266 } else { 267 268 update_option('ept_opt_use_pause_tweet', false); 269 } 270 263 271 //pause auto tweet - start time 264 272 if (isset($_POST['ept_opt_start_pause_time'])) { … … 457 465 $maxAgeLimit = ept_opt_MAX_AGE_LIMIT; 458 466 } 467 468 //use pause tweet? 469 $use_pause_tweet = get_option('ept_opt_use_pause_tweet'); 470 if (!isset($use_pause_tweet)) { 471 $use_pause_tweet = ""; 472 } elseif ($use_pause_tweet) 473 $use_pause_tweet = "checked"; 474 else 475 $use_pause_tweet=""; 459 476 460 477 //pause auto tweet - start time … … 633 650 634 651 <div class="option"> 635 <label class="ttip">' . __('Start Time to Pause Tweet: ', 'Evergreen') . ': </label> 636 <input type="text" id="ept_opt_start_pause_time" value="' . $ept_opt_start_pause_time . '" name="ept_opt_start_pause_time" /> 637 <strong>Default 22:00</strong> 652 <label for="ept_opt_use_pause_tweet">' . __('Prevent Automatic Tweeting Between Certain Hours?: ', 'Evergreen') . '</label> 653 <input onchange="return showPauseTweet()" type="checkbox" name="ept_opt_use_pause_tweet" id="ept_opt_use_pause_tweet" ' . $use_pause_tweet . ' /> 638 654 </div> 639 655 640 <div class="option"> 641 <label class="ttip">' . __('End Time to Pause Tweet: ', 'Evergreen') . ': </label> 642 <input type="text" id="ept_opt_end_pause_time" value="' . $ept_opt_end_pause_time . '" name="ept_opt_end_pause_time" /> 643 <strong>Default 05:00</strong> 656 <div id="pausetweet"> 657 <div class="option"> 658 <label class="ttip">' . __('Start Time to Pause Tweet: ', 'Evergreen') . ': </label> 659 <input type="text" id="ept_opt_start_pause_time" value="' . $ept_opt_start_pause_time . '" name="ept_opt_start_pause_time" /> 660 <strong>Default 22:00</strong> 661 </div> 662 663 <div class="option"> 664 <label class="ttip">' . __('End Time to Pause Tweet: ', 'Evergreen') . ': </label> 665 <input type="text" id="ept_opt_end_pause_time" value="' . $ept_opt_end_pause_time . '" name="ept_opt_end_pause_time" /> 666 <strong>Default 05:00</strong> 667 </div> 644 668 </div> 645 669 … … 750 774 } 751 775 } 776 777 function showPauseTweet() 778 { 779 780 781 if((document.getElementById("ept_opt_use_pause_tweet").checked)) 782 { 783 document.getElementById("pausetweet").style.display="block"; 784 } 785 else 786 { 787 document.getElementById("pausetweet").style.display="none"; 788 } 789 } 752 790 function setFormAction() 753 791 { … … 766 804 showURLAPI(); 767 805 showshortener(); 806 showPauseTweet(); 768 807 769 808 </script>'); -
evergreen-post-tweeter/trunk/ept-core.php
r725789 r729135 141 141 //check last tweet time against set interval and span 142 142 //also check if it isn't in pause time 143 if (ept_opt_update_time() && ept_in_pause_time()) {143 if (ept_opt_update_time() && ! ept_in_pause_time()) { 144 144 update_option('ept_opt_last_update', time()); 145 145 ept_opt_tweet_old_post(); … … 615 615 function ept_in_pause_time() 616 616 { 617 $ept_opt_use_pause_tweet = get_option('ept_opt_use_pause_tweet'); 618 617 619 //pause auto tweet - start time 618 620 $ept_opt_start_pause_time = get_option('ept_opt_start_pause_time'); … … 627 629 } 628 630 631 if (! $ept_opt_use_pause_tweet) { 632 return false; 633 } 634 629 635 if (strtotime($ept_opt_start_pause_time) > strtotime($ept_opt_end_pause_time)) 630 636 if (strtotime($ept_opt_start_pause_time) < current_time('timestamp', 0) || 631 637 current_time('timestamp', 0) < strtotime($ept_opt_end_pause_time)) { 638 $ret = true; 639 } else { 632 640 $ret = false; 633 } else {634 $ret = true;635 641 } 636 642 else { 637 643 if (strtotime($ept_opt_start_pause_time) < current_time('timestamp', 0) && 638 644 current_time('timestamp', 0) < strtotime($ept_opt_end_pause_time)) { 645 $ret = true; 646 } else { 639 647 $ret = false; 640 } else {641 $ret = true;642 648 } 643 649 } … … 718 724 update_option('ept_opt_use_inline_hashtags',''); 719 725 update_option('ept_opt_use_url_shortner',''); 726 update_option('ept_opt_use_pause_tweet',''); 720 727 update_option('ept_cat_tweet', ''); 721 728 update_option('ept_tag_tweet', ''); -
evergreen-post-tweeter/trunk/evergreen.php
r725789 r729135 3 3 Plugin Name: Evergreen Post Tweeter 4 4 Plugin URI: http://www.leavingworkbehind.com/evergreen-post-tweeter/ 5 Description: WARNING!! This plugin is currently not functional but that we'll have a patch up ASAP!!!Evergreen Post Tweeter enables you to automatically tweet out links to old posts based upon a tag or tags.5 Description: Evergreen Post Tweeter enables you to automatically tweet out links to old posts based upon a tag or tags. 6 6 Author: Tom Ewer 7 Version: 1.5. 27 Version: 1.5.3 8 8 Author URI: http://www.leavingworkbehind.com/about-me/ 9 9 */ -
evergreen-post-tweeter/trunk/readme.txt
r725789 r729135 13 13 14 14 == Description == 15 16 WARNING!! This plugin is currently not functional but that we'll have a patch up ASAP!!!17 15 18 16 Evergreen Post Tweeter enables you to automatically and periodically tweet out links to old posts based upon a tag or tags. … … 58 56 == Upgrade Notice == 59 57 58 = 1.5.3 = 59 * Fix Twitter API. 60 60 61 = 1.5.2 = 61 62 * Fix bug on pause time option. … … 83 84 == Changelog == 84 85 86 = 1.5.3 = 87 * Fix Twitter API. 88 85 89 = 1.5.2 = 86 90 * Fix bug on pause time option.
Note: See TracChangeset
for help on using the changeset viewer.