Changeset 790780
- Timestamp:
- 10/20/2013 07:42:08 AM (12 years ago)
- Location:
- globalfeed/trunk
- Files:
-
- 10 edited
-
class-mb_globalfeed_feed.php (modified) (8 diffs)
-
feeds/mb_facebook/mb_facebook.php (modified) (23 diffs)
-
feeds/mb_facebook/pages/js/mb_facebook.js (modified) (2 diffs)
-
feeds/mb_twitter/mb_twitter.php (modified) (8 diffs)
-
feeds/mb_twitter/pages/js/mb_twitter.js (modified) (2 diffs)
-
feeds/mb_twitter/pages/setup.php (modified) (2 diffs)
-
feeds/mb_youtube/mb_youtube.php (modified) (9 diffs)
-
feeds/mbgf_rss/mbgf_rss.php (modified) (16 diffs)
-
mb_globalfeed.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
globalfeed/trunk/class-mb_globalfeed_feed.php
r593074 r790780 30 30 * @var str 31 31 */ 32 pr ivate$feed_name = 'Example Feed';32 protected $feed_name = 'Example Feed'; 33 33 34 34 /** … … 37 37 * @var str 38 38 */ 39 pr ivate$feed_slug = 'example_feed';39 protected $feed_slug = 'example_feed'; 40 40 41 41 /** … … 44 44 * @var str 45 45 */ 46 pr ivate$feed_type = 'request';46 protected $feed_type = 'request'; 47 47 48 48 /** … … 51 51 * @var array 52 52 */ 53 pr ivate$pages_to_show = array(53 protected $pages_to_show = array( 54 54 'all' 55 55 ); … … 59 59 * @var array 60 60 */ 61 pr ivate$pages_not_to_show = array(61 protected $pages_not_to_show = array( 62 62 63 63 ); … … 70 70 * @var array $feed_options 71 71 */ 72 pr ivate$feed_options = array(72 protected $feed_options = array( 73 73 'auto_contain_feed_items' => true 74 74 ); … … 79 79 * @var type array 80 80 */ 81 pr ivate$allowed_actions = array(81 protected $allowed_actions = array( 82 82 'update_feed', 83 83 'do_maintenance' … … 232 232 233 233 /** 234 * This function take the rawdata returned by the feed source (ie Titter, Facebook etc...) and converts it into 234 * Adds an alert that should be displayed to the user 235 * 236 * If an alert with the same $alert_code already exists, it will be overwritten. 237 * 238 * @global type $current_user 239 * 240 * @param str $alert_code A slug-style code for the alert 241 * @param str $alert_text The alert text 242 * @param type $important Whether the alert should be shown as a notice or an error 243 * @param bool $sitewide (optional, defaults to false) Whether the alert should be shown sitewide, or just within GlobalFeed. 244 * @param type $require_priv What privilege the alert requires to be seen. '' if none. 245 * @param type $dismissable Whether the alert should be dismissable by the user 246 */ 247 public function add_alert( $alert_code, $alert_text, $important = false, $sitewide = false, $require_priv = 'manage_options', $dismissable = true ) { 248 global $current_user, $mb_globalfeed; 249 250 if (!isset($this->feed_options['alerts'])) 251 $this->feed_options['alerts'] = array(); 252 253 $this->feed_options['alerts'][$alert_code] = array( 254 'alert_code' => $alert_code, 255 'alert_text' => $alert_text, 256 'sitewide' => $sitewide, 257 'hidden' => false, 258 'remind' => 0, 259 'important' => $important, 260 'require_priv' => $require_priv, 261 'never_show' => (isset($this->feed_options['alerts'][$alert_code]) ? $this->feed_options['alerts'][$alert_code]['never_show'] : false), 262 'dismissable'=> $dismissable, 263 ); 264 265 $this->register_feed(true); 266 267 delete_user_meta($current_user->ID, $mb_globalfeed->post_type_namespace() . $this->feed_slug . "_hide_alert_" . $alert_code); 268 } 269 270 /** 271 * When an alert no longer applies, hide it from the user. 272 * 273 * @param type $alert_code 274 */ 275 function hide_alert( $alert_code ) { 276 if (!isset($this->feed_options['alerts'])) 277 return; 278 279 if ( isset($this->feed_options['alerts'][$alert_code]) ) 280 $this->feed_options['alerts'][$alert_code]['hidden'] = true; 281 282 $this->register_feed(true); 283 } 284 285 /** 286 * When several alerts no longer apply, hide them from the user. 287 * 288 * @param array $alert_codes 289 */ 290 function hide_alerts( $alert_codes ) { 291 if (!isset($this->feed_options['alerts'])) 292 return; 293 294 foreach ($alert_codes as $alert_code) { 295 if ( isset($this->feed_options['alerts'][$alert_code]) ) 296 $this->feed_options['alerts'][$alert_code]['hidden'] = true; 297 } 298 299 $this->register_feed(true); 300 } 301 302 /** 303 * Shows any queued alerts. Also detects if the user hides an alert 304 * 305 * Called by WordPress Action 'admin_notices' 306 * 307 */ 308 function show_alerts() { 309 global $current_user, $mb_globalfeed; 310 311 // Check if there are alerts 312 if ( !count($this->feed_options['alerts']) ) 313 return; 314 315 $hide_text = __('Hide', 'mb_globalfeed'); 316 $never_show_text = __('Never show again', 'mb_globalfeed'); 317 318 // Used for show/hide urls 319 $server_args = array(); 320 parse_str($_SERVER['QUERY_STRING'], $server_args); 321 322 // Loop through alerts 323 foreach ($this->feed_options['alerts'] as $alert_code => $alert) { 324 // Check if this alert should be hidden from the user 325 $hide_alert = $mb_globalfeed->post_type_namespace() . $this->feed_slug . "_hide_alert_" . $alert['alert_code']; 326 $never_show_alert = $mb_globalfeed->post_type_namespace() . $this->feed_slug . "_never_show_alert_" . $alert['alert_code']; 327 328 // Check if alert show status changed 329 if ( isset($_GET[$hide_alert]) ) { 330 add_user_meta($current_user->ID, $hide_alert, true); 331 continue; 332 } 333 334 if ( isset($_GET[$never_show_alert]) ) { 335 $this->globalfeed->print_debug_info("Never show"); 336 $this->feed_options['alerts'][$alert_code]['never_show'] = true; 337 $this->register_feed(true); 338 continue; 339 } 340 341 // Check if alert is disabled -- but make sure we catch anything telling us to hide the alert (but make sure the user has permission) 342 if ( ( $alert['require_priv'] == '' || current_user_can($alert['require_priv']) ) && ( 343 // Is this alert disabled? 344 $alert['hidden'] || $alert['never_show'] 345 346 // Check if the alert should be shown accross WP-Admin 347 || ( $mb_globalfeed->in_admin() === false && !$alert['sitewide'] ) 348 349 // Check if the user has previously hidden this alert 350 || get_user_meta($current_user->ID, $hide_alert, true) === true ) ) 351 continue; 352 353 // This alert should be shown to the user 354 echo "<div class='{$alert['alert_code']} " . ($alert['important'] ? 'error' : 'updated') . "'><p>{$alert['alert_text']}</p>"; 355 356 if ( $alert['dismissable'] ) { 357 $hide_addr = http_build_query(array_merge($server_args, array($hide_alert=>1))); 358 $never_addr= http_build_query(array_merge($server_args, array($never_show_alert=>1))); 359 echo "<div class='align_right'><a href='?$hide_addr' title='$hide_text'>$hide_text</a> | <a href='?$never_addr' title='$never_show_text'>$never_show_text</a></div></div>"; 360 } else 361 echo '</div>'; 362 } 363 } 364 365 /** 366 * Gets the translated text for a message for the feed. 367 * @param string $message_slug The message text to retrieve. 368 * @return string The translated message text 369 */ 370 function get_message($message_slug) { 371 return ''; 372 } 373 374 /** 375 * This function take the rawdata returned by the feed source (ie Twitter, Facebook etc...) and converts it into 235 376 * the array format expected by $mb_globalfeed->save_feed_items(), then it saves it using this function. 236 377 * -
globalfeed/trunk/feeds/mb_facebook/mb_facebook.php
r711609 r790780 39 39 * @var str 40 40 */ 41 pr ivate$feed_name = 'Facebook Connect';41 protected $feed_name = 'Facebook Connect'; 42 42 43 43 /** … … 46 46 * @var str 47 47 */ 48 pr ivate$feed_slug = 'facebook_connect';48 protected $feed_slug = 'facebook_connect'; 49 49 50 50 /** … … 53 53 * @var str 54 54 */ 55 pr ivate$feed_type = 'request';55 protected $feed_type = 'request'; 56 56 57 57 /** … … 59 59 * @var boolean 60 60 */ 61 pr ivate$auto_interupt_flow = true;61 protected $auto_interupt_flow = true; 62 62 63 63 /** … … 66 66 * @var array 67 67 */ 68 pr ivate$pages_to_show = array(68 protected $pages_to_show = array( 69 69 'all' => 'all' 70 70 ); … … 74 74 * @var array 75 75 */ 76 pr ivate$pages_not_to_show = array(76 protected $pages_not_to_show = array( 77 77 78 78 ); 79 79 80 pr ivate$admin_pages = array();80 protected $admin_pages = array(); 81 81 82 82 … … 85 85 * @var mb_globalfeed 86 86 */ 87 pr ivate$globalfeed;87 protected $globalfeed; 88 88 89 89 … … 127 127 'override_post_time_on_timezone_discrepency' => false, 128 128 'show_posts_from_other_users' => false, 129 'alerts' => array(), 129 130 ); 130 131 … … 136 137 * @var array $feed_options 137 138 */ 138 pr ivate$feed_options = null;139 protected $feed_options = null; 139 140 140 141 public function get_queryvar() { … … 215 216 // These action are related to the setup while were in admin... 216 217 if (is_admin()) { 218 add_action( 'wp_ajax_mbgf_facebook_connect_ajax_get_fb_obj', array( &$this, 'ajax_get_fb_obj' )); 217 219 add_action( 'wp_ajax_mbgf_facebook_connect_set_app_info', array( &$this, 'set_app_info' )); 218 220 add_action( 'wp_ajax_mbgf_facebook_connect_is_authed', array( &$this, 'ajax_app_is_authed' )); … … 223 225 add_action( 'wp_ajax_mbgf_facebook_connect_manual_feed_update', array( &$this, 'ajax_do_update' )); 224 226 227 // General Hooks 228 add_action( 'admin_notices', array( &$this, 'show_alerts' ) ); 225 229 226 230 add_action( 'mbgf_feed_menu-' . $this->get_slug(), array(&$this, 'register_admin_menus')); 227 231 add_action( 'mbgf_unregister_feed-' . $this->get_slug(), array( &$this, 'unregister_feed') ); 232 } 233 } 234 235 function get_message($message_slug) { 236 $text_domain = 'mb_globalfeed'; 237 238 switch ($message_slug) { 239 case 'image_introspection_error': 240 return __('GlobalFeed Facebook Connect encountered an error performing introspection on image elements while fetching additional data from Facebook. <br /><br />If this continues to occur please report it using the bug report feature.', $text_domain); 241 case 'story_introspection_error': 242 return __('GlobalFeed Facebook Connect encountered an error performing introspection on story elements while fetching additional data from Facebook. <br /><br />If this continues to occur please report it using the bug report feature.', $text_domain); 243 case 'need_reauth': 244 return __('GlobalFeed Facebook Connect needs you to reauthenticate the application with Facebook to continue receiving updates.', $text_domain); 245 case 'rate_limiting': 246 return __('GlobalFeed Facebook Connect is currently being rate limited. If you have issued a manual update please wait several minutes. Otherwise please reduce the update frequency.', $text_domain); 247 default: 248 return 'GlobalFeed Facebook error 404: Unknown message slug.'; 228 249 } 229 250 } … … 282 303 $this->feed_options['ouath_app_expires'] = ''; 283 304 305 $this->feed_options['last_feed_update'] = 0; 306 284 307 $this->register_feed(true); 285 308 … … 380 403 die( json_encode(false) ); 381 404 } 405 } 406 407 /** 408 * Serves as a runner to fetch facebook objects from Facebook so that the 409 * client browser doesn't have to contact Facebook directly. 410 * @return type 411 */ 412 public function ajax_get_fb_obj() { 413 check_admin_referer( 'facebook-connect-settings_main' ); 414 wp_verify_nonce( 'facebook-connect-settings_main' ); 415 416 // Check that the Facebook object was provided 417 if (!isset($_GET['fb_obj']) || empty($_GET['fb_obj'])) { 418 header('HTTP/1.1 500 Internal Server Error', true, 500); 419 die('{"error": "FB Object not specified in request."}'); 420 } 421 422 $obj_id = $_GET['fb_obj']; 423 424 // Validate the values we've received 425 if (preg_match('/^[0-9a-zA-Z_-]+$/', $obj_id) == 0) { 426 header('HTTP/1.1 500 Internal Server Error', true, 500); 427 die('{"error": "Input arguments are not of the right format"}'); 428 } 429 430 // Check that GlobalFeed has been authorized with facebook 431 if ( empty($this->feed_options['oauth_user_token']) ) { 432 header('HTTP/1.1 400 No OAUTH access token', true, 400); 433 die('{"error": "The application has not yet been authorized with facebook."}'); 434 return; 435 } 436 437 // Fetch the object from facebook 438 $fb_obj = wp_remote_get("https://graph.facebook.com/$obj_id?metadata=1&access_token={$this->feed_options['oauth_user_token']}"); 439 440 // Check for an error 441 if (is_wp_error($fb_obj) || $fb_obj['response']['code'] != '200') { 442 header("HTTP/1.1 {$fb_obj['response']['code']} {$fb_obj['response']['message']}", true, (int) $fb_obj['response']['code']); 443 if (isset($fb_obj['body'])) { 444 die($fb_obj['body']); 445 } else { 446 die('{"error": "An unknown error occured retrievint the facebook object. Please try again."}'); 447 } 448 } 449 450 die ($fb_obj['body']); 382 451 } 383 452 … … 632 701 } 633 702 } 634 635 703 } 636 704 exit; … … 667 735 $globalfeed = &$this->globalfeed; 668 736 $feed_options = &$this->feed_options; 669 $globalfeed->print_debug_info('Update Feed Called.', $this->feed_slug);670 737 671 738 // Check and make sure the oauth token is set 672 if ( empty($feed_options['oauth_user_token']) ) 739 if ( empty($feed_options['oauth_user_token']) ) { 740 $globalfeed->print_debug_info('No OAUTH User Token.', $this->feed_slug); 673 741 return; 742 } 674 743 675 744 // Different facebook objects require that we query different things … … 683 752 } 684 753 685 $graph_url = "https://graph.facebook.com/{$feed_options['object_to_subscribe']}/{$query_object}?access_token={$access_token}&since={$feed_options['last_feed_update']}&limit={$feed_options['max_feed_items']}"; 754 $graph_url = "https://graph.facebook.com/{$feed_options['object_to_subscribe']}/{$query_object}?access_token={$access_token}&since={$feed_options['last_feed_update']}"; 755 756 if ($feed_options['max_feed_items'] > 0) 757 $graph_url .= "&limit={$feed_options['max_feed_items']}"; 758 686 759 $updates = wp_remote_get($graph_url); 687 760 688 if (is_wp_error($updates) || $updates['response']['code'] != '200') 761 if (is_wp_error($updates) || $updates['response']['code'] != '200') { 762 if (isset($updates['body'])) { 763 $body = json_decode($updates['body'], true); 764 765 if (!isset($body['error']) || !isset($body['error']['code'])) { 766 $this->globalfeed->print_debug_info("this is whats happening"); 767 $this->add_alert('unknown error', "An unknown error occured with an update request. The response was {$updates['response']['code']}: {$updates['response']['message']}."); 768 return false; 769 } 770 771 $ival = intval($body['error']['code']); 772 if ( in_array( $ival, array(190, 102, 10) ) || ( $ival >= 200 && $ival <= 299 ) ) { 773 $this->add_alert('need_reauth', $this->get_message('need_reauth'), true, true); 774 } elseif ( in_array($ival, array(1, 2, 4, 17)) ) { 775 $this->add_alert('rate_limiting', $this->get_message('rate_limiting'), false, false); 776 } 777 } else { 778 $this->globalfeed->print_debug_info('unknown error'); 779 $this->add_alert('unknown_error', "An unknown error occured with an update request. The response was {$updates['response']['code']}: {$updates['response']['message']}."); 780 } 781 689 782 return false; 783 } 784 785 $this->hide_alerts(array('need_reauth', 'rate_limiting', 'unknown_error')); 690 786 691 787 // Use the regex to replace numerical values to strings for older versions of php 692 $updates = json_decode( preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $updates['body']) ); 693 694 $globalfeed->print_debug_info($updates, 'mb_facebook'); 788 $updates = json_decode( preg_replace('/("\w+"):([0-9.]+)/', '\\1:"\\2"', $updates['body']), false); 695 789 696 790 $feed_items = array(); … … 735 829 switch ($update->type) { 736 830 case 'video' : 737 $post_args['post_title'] = $ update->name;738 $post_args['post_excerpt'] = $ update->description;831 $post_args['post_title'] = $this->get_prop($update, 'name');//$update->name; 832 $post_args['post_excerpt'] = $this->get_prop($update, 'description');//$update->description; 739 833 $post_args['post_format'] = 'video'; 740 $post_args['meta']['source'] = $ update->source;741 $post_args['meta']['picture'] = $ update->picture;742 $post_args['meta']['link'] = $ update->link;743 $post_args['meta']['caption'] = $ update->caption;834 $post_args['meta']['source'] = $this->get_prop($update, 'source');//$update->source; 835 $post_args['meta']['picture'] = $this->get_prop($update, 'picture');//$update->picture; 836 $post_args['meta']['link'] = $this->get_prop($update, 'link');//$update->link; 837 $post_args['meta']['caption'] = $this->get_prop($update, 'caption');//$update->caption; 744 838 745 839 // figure out where this video resides to display the correct content. … … 748 842 if ($globalfeed->media_display_mode() == 'embed') { 749 843 $content_args['media_format'] = 'video'; 750 $content_args['media_info'] = array('facebook_embed_html' => array_pop(array_values($update->format)), 'width'=>'100%'); 844 $content_args['media_info'] = array( 845 'facebook_embed_html' => array_pop(array_values($this->get_prop($update, 'format'))), 846 'width'=>'100%' 847 ); 751 848 } else { 752 $post_args['meta']['embed_html'] = array_pop(array_values($ update->format));849 $post_args['meta']['embed_html'] = array_pop(array_values($this->get_prop($update, 'format'))); 753 850 } 754 851 } else { … … 757 854 // The link is to a youtube video. Extract the id, then call the embedder. 758 855 $post_args['meta']['video_source'] = 'youtube'; 759 $globalfeed->print_debug_info("Parsing youtube id:" . $post_args['meta']['link']);760 856 parse_str( parse_url( $post_args['meta']['link'], PHP_URL_QUERY ), $url_params ); 761 857 $post_args['meta']['youtube_id'] = $url_params['v']; 762 // $post_args['meta']['youtube_id'] = substr( $post_args['meta']['link'], strripos( $post_args['meta']['link'], '/' ) + 9 );763 858 764 859 $content_args['media_format'] = 'video'; … … 769 864 case 'link' : 770 865 $post_args['post_format'] = 'link'; 771 $post_args['meta']['link'] = $ update->link;772 $post_args['meta']['link_title'] = $ update->name;773 $post_args['meta']['description'] = $ update->description;774 $post_args['meta']['picture'] = $ update->picture;866 $post_args['meta']['link'] = $this->get_prop($update, 'link'); 867 $post_args['meta']['link_title'] = $this->get_prop($update, 'name'); 868 $post_args['meta']['description'] = $this->get_prop($update, 'link'); 869 $post_args['meta']['picture'] = $this->get_prop($update, 'link'); 775 870 776 871 $content_args['media_format'] = 'link'; … … 786 881 if ( !is_wp_error($img) ) 787 882 $post_args['meta']['picture'] = $img['headers']['location']; 788 else 789 $globalfeed->print_debug_info ($img); 790 // $globalfeed->print_debug_info($update); 791 $post_args['meta']['link'] = $update->link; 883 else { 884 $this->add_alert('image_introspection_error', $this->get_message('image_introspection_error'), false, false); 885 } 886 887 $post_args['meta']['link'] = $this->get_prop($update, 'link');//$update->link; 792 888 $content_args['media_format'] = 'image'; 793 889 $content_args['media_info'] = array('source_url' => $post_args['meta']['picture']); … … 816 912 $graph_url = "https://graph.facebook.com/{$value[0]->id}?access_token={$access_token}&metadata=1"; 817 913 $introspect = wp_remote_get($graph_url); 818 819 if (is_wp_error($introspect)) 820 return false; 821 $introspect = json_decode($introspect['body']); 822 $type = $introspect->type; 914 915 if ( is_wp_error($introspect) ) { 916 $this->add_alert('story_introspection_error', $this->get_message('story_introspection_error'), false, false); 917 } else { 918 $introspect = json_decode($introspect['body']); 919 $type = $introspect->type; 920 } 823 921 } 824 922 … … 874 972 return 0; 875 973 } 974 } 975 976 /** 977 * Retrieves the property from the object or array or null if not defined. 978 * @param type $obj 979 * @param type $prop 980 * @return type 981 */ 982 private function get_prop($obj, $prop) { 983 if ( is_object($obj) ) 984 return isset($obj->$prop) ? $obj->$prop : null; 985 elseif ( is_array($obj) ) 986 return isset($obj[$prop]) ? $obj[$prop] : null; 987 else 988 return null; 876 989 } 877 990 -
globalfeed/trunk/feeds/mb_facebook/pages/js/mb_facebook.js
r711217 r790780 4 4 function get_fb_object( object_id, element_id ) { 5 5 return jQuery.ajax({ 6 url: 'https://graph.facebook.com/' + object_id + "?metadata=1", 7 dataType: 'jsonp', 8 data: {}, 6 url: ajaxurl, 7 dataType: 'json', 8 data: { 9 action:'mbgf_facebook_connect_ajax_get_fb_obj', 10 _wpnonce:jQuery('#_wpnonce').val(), 11 fb_obj: object_id 12 }, 13 crossDomain: true, 9 14 statusCode: { 10 15 200: function (response) { … … 89 94 checkAuthWindow( statusdiv, fail, redir_url ); 90 95 }, 1000); 91 //authWindowChecker = setTimeout('checkAuthWindow("' + statusdiv + ',' + fail + ',' + '")', 1000);92 96 return; 93 97 } 98 99 error_count = 0; 94 100 function checkAuthWindow( statusdiv, fail, redir_url ) { 95 101 clearTimeout(authWindowChecker); -
globalfeed/trunk/feeds/mb_twitter/mb_twitter.php
r790774 r790780 644 644 $parameters = array( 645 645 'oauth_callback' => get_bloginfo('wpurl').'/', 646 // 'x_auth_access_type' => 'read'647 646 ); 648 647 … … 744 743 'oauth_consumer_key' => $this->feed_options['consumer_key'], 745 744 'oauth_nonce' => $_SESSION['state'], 746 // 'oauth_nonce' => "f9b649e39402a68e3ebbdbd2f8968fd3",747 745 'oauth_signature_method' => 'HMAC-SHA1', 748 746 'oauth_timestamp' => (string) time(), 749 // 'oauth_timestamp' => "1382247124",750 // 'oauth_token' => $this->feed_options['oauth_access_token'],751 747 'oauth_version' => '1.0', 752 // 'oauth_callback' => get_bloginfo('wpurl').'/',753 // 'x_auth_access_type' => 'read'754 748 ); 755 749 756 757 758 // if ( !empty($this->feed_options['oauth_access_token']) ) 759 // $default_parameters['oauth_token'] = $this->feed_options['oauth_access_token']; 760 761 // Parse the default parameters 762 // $parameters = wp_parse_args($parameters, $default_parameters); 750 if (!empty($this->feed_options['oauth_access_token'])) 751 $default_parameters['oauth_token'] = $this->feed_options['oauth_access_token']; 752 763 753 $auth_params = wp_parse_args($auth_params, $default_parameters); 764 754 $all_params = wp_parse_args($parameters, $auth_params); … … 772 762 ksort($auth_params); 773 763 774 $this->globalfeed->print_debug_info($auth_params);775 776 $this->globalfeed->print_debug_info($parameters);777 778 764 $endpoint .= '?'; 779 765 foreach ( $parameters as $key => $value ) … … 782 768 $endpoint = substr($endpoint, 0, -1); 783 769 784 $this->globalfeed->print_debug_info($endpoint);785 786 770 $auth_header = "OAuth "; 787 771 foreach ( $auth_params as $key => $value ) 788 772 $auth_header .= rawurlencode($key) . "=\"" . rawurlencode($value) . "\", "; 789 790 $this->globalfeed->print_debug_info(substr($auth_header, 0, -2));791 773 792 774 // Execute the request, and return whatever results … … 803 785 */ 804 786 private function generate_twitter_request_signature( $endpoint, $method, $parameters ) { 805 $this->globalfeed->print_debug_info("------------------------Beginning signature generation");806 807 787 // Sort the parameters alphabetically 808 788 ksort($parameters); … … 818 798 // The base string is the parameter string appendd to the base string (as per oauth spec) 819 799 $base_str = strtoupper($method) . '&' . rawurlencode($endpoint) . '&' . rawurlencode($param_str); 820 $this->globalfeed->print_debug_info('base string:');821 $this->globalfeed->print_debug_info($base_str);822 800 823 801 // Build the signing key … … 827 805 if ( !empty($this->feed_options['oauth_access_token_secret']) ) 828 806 $signing_key .= rawurlencode($this->feed_options['oauth_access_token_secret']); 829 830 $this->globalfeed->print_debug_info('signing key:');831 $this->globalfeed->print_debug_info($signing_key);832 833 $this->globalfeed->print_debug_info("------------------------Done signature generation");834 807 835 808 // Create and return the signature … … 938 911 939 912 // Use the regex to replace numerical values to strings for older versions of php 940 $updates = json_decode( preg_replace('/("\w+"):( \d+)/', '\\1:"\\2"', $request['body']), true );913 $updates = json_decode( preg_replace('/("\w+"):([0-9.]+)/', '\\1:"\\2"', $request['body']), true ); 941 914 942 915 // Check that we actually have content -
globalfeed/trunk/feeds/mb_twitter/pages/js/mb_twitter.js
r612743 r790780 20 20 var tw_object_sn_match = new RegExp(/^(\?|@)??([A-Za-z0-9_]+)$/); // Check for a user screen name 21 21 var querystring = ''; 22 22 var data = { action: 'mbgf_twitter_connect_get_user', _wpnonce:jQuery('#_wpnonce').val() }; 23 23 24 // Check which object type we have... 24 25 if (tw_object_id_match.exec( tw_object_id )){ 25 querystring = '?user_id=' + tw_object_id + '&callback=?'; 26 data['user_id'] = tw_object_id; 27 // querystring = '?user_id=' + tw_object_id + '&callback=?'; 26 28 } else if (tw_object_sn_match.exec( tw_object_id )){ 27 29 tw_object_id = tw_object_sn_match.exec( tw_object_id );// Replace question marks 28 querystring = '?screen_name=' + tw_object_id[tw_object_id.length - 1] + '&callback=?'; 30 // querystring = '?screen_name=' + tw_object_id[tw_object_id.length - 1] + '&callback=?'; 31 data['screen_name'] = tw_object_id[tw_object_id.length - 1]; 29 32 } else { 30 33 showMessage('You must provide a valid object id (must be only numbers) or screen name (can be letters, numbers or underscores)', 'tw_object_id', true); … … 39 42 40 43 // Check that the object ID is valid, and that we have access to that object. 44 // jQuery.post(ajaxurl, {action:'mbgf_twitter_connect_is_authed',_wpnonce:jQuery('#_wpnonce').val()} 41 45 return jQuery.ajax({ 42 46 type: 'GET', 43 url: 'https://api.twitter.com/1/users/lookup.json' + querystring,44 dataType: 'json p',45 data: {},47 url: ajaxurl, 48 dataType: 'json', 49 data: data, 46 50 timeout: 3000, 47 51 statusCode: { 48 52 200: function (response) { 49 response = response[0];// Data received from Twitter is an array50 51 53 // Save the twitter obj id publicly 52 54 mb_twitter_info.tw_obj_id = response.id; -
globalfeed/trunk/feeds/mb_twitter/pages/setup.php
r612743 r790780 24 24 <div id="step-1"> 25 25 <p><h2>How would you like to connect to Twitter?</h2></p> 26 <div class="optgrp bottom-button" style="min-height:270px;">27 <p class="center"><h2>Without a Twitter App</h2></p>28 <p>29 Setting up Twitter Connect without an App is the quickest and easiest way to get started with Twitter Connect.30 </p>31 <p>32 When you setup without using a Twitter App, Twitter Connect will not authenticate with Twitter33 (although all of your data is still communicated over SSL.) The caveat to this approach34 is that if your site is located on shared hosting Twitter Connect may become rate limited by Twitter35 and may not be able to consistently fetch content.36 </p>37 <p>38 If you encounter issues with not receiving new content while using Twitter Connect without a Twitter App39 you can always supply App information to switch to Authenticated mode at a later time.40 </p>41 <p class="center"><input type="button" id="setup_without_app" value="Without a Twitter App" class="button-primary" /></p>42 </div>43 26 <div class="optgrp" style="min-height:270px;"> 44 27 <p class="center"><h2>With a Twitter App</h2></p> … … 51 34 </p> 52 35 <p class="center bottom-button"><input type="button" id="setup_with_app" value="With a Twitter App" class="button-primary" /></p> 36 </div> 37 <div class="optgrp bottom-button" style="min-height:270px;"> 38 <p class="center"><h2>Without a Twitter App</h2></p> 39 <p> 40 Oops! With the new Twitter API, we're unable to offer this feature. If you were previously setup with this option - we apologize! You will need to setup GlobalFeed with a Twitter application. 41 </p> 53 42 </div> 54 43 </div> -
globalfeed/trunk/feeds/mb_youtube/mb_youtube.php
r625019 r790780 40 40 * @var str 41 41 */ 42 pr ivate$feed_name = 'YouTube Connect';42 protected $feed_name = 'YouTube Connect'; 43 43 44 44 /** … … 47 47 * @var str 48 48 */ 49 pr ivate$feed_slug = 'youtube_connect';49 protected $feed_slug = 'youtube_connect'; 50 50 51 51 /** … … 54 54 * @var str 55 55 */ 56 pr ivate$feed_type = 'request';56 protected $feed_type = 'request'; 57 57 58 58 /** … … 60 60 * @var boolean 61 61 */ 62 pr ivate$auto_interupt_flow = true;62 protected $auto_interupt_flow = true; 63 63 64 64 /** … … 67 67 * @var array 68 68 */ 69 pr ivate$pages_to_show = array(69 protected $pages_to_show = array( 70 70 'all' => 'all' 71 71 ); … … 75 75 * @var array 76 76 */ 77 pr ivate$pages_not_to_show = array(77 protected $pages_not_to_show = array( 78 78 79 79 ); … … 88 88 * @var type 89 89 */ 90 pr ivate$globalfeed;90 protected $globalfeed; 91 91 92 92 private $_apiurl = 'http://gdata.youtube.com/'; … … 127 127 'show_welcome_message' => false, 128 128 'use_https' => true, 129 'override_post_time_on_timezone_discrepency' => false 129 'override_post_time_on_timezone_discrepency' => false, 130 'alerts' => array(), 130 131 ); 131 132 … … 137 138 * @var array $feed_options 138 139 */ 139 pr ivate$feed_options = null;140 protected $feed_options = null; 140 141 141 142 /** -
globalfeed/trunk/feeds/mbgf_rss/mbgf_rss.php
r625019 r790780 43 43 * @var str 44 44 */ 45 pr ivate$feed_name = 'MB RSS';45 protected $feed_name = 'MB RSS'; 46 46 47 47 /** … … 50 50 * @var str 51 51 */ 52 pr ivate$feed_slug = 'mbgf_rss';52 protected $feed_slug = 'mbgf_rss'; 53 53 54 54 /** … … 57 57 * @var str 58 58 */ 59 pr ivate$feed_type = 'request';59 protected $feed_type = 'request'; 60 60 61 61 /** … … 63 63 * @var boolean 64 64 */ 65 pr ivate$auto_interupt_flow = true;65 protected $auto_interupt_flow = true; 66 66 67 67 /** … … 70 70 * @var array 71 71 */ 72 pr ivate$pages_to_show = array(72 protected $pages_to_show = array( 73 73 'all' => 'all' 74 74 ); … … 78 78 * @var array 79 79 */ 80 pr ivate$pages_not_to_show = array(80 protected $pages_not_to_show = array( 81 81 82 82 ); … … 97 97 * @var type 98 98 */ 99 pr ivate$globalfeed;99 protected $globalfeed; 100 100 101 101 /** … … 123 123 'errors' => array(), 124 124 'override_post_time_on_timezone_discrepency' => false, 125 'alerts' => array(), 125 126 ); 126 127 … … 132 133 * @var array $feed_options 133 134 */ 134 pr ivate$feed_options = null;135 protected $feed_options = null; 135 136 136 137 /** … … 177 178 add_action( 'wp_ajax_mbgf_rss_reset_feed_defaults', array( &$this, 'reset_feed_defaults' ) ); 178 179 add_action( 'mbgf_unregister_feed-' . $this->get_slug(), array( &$this, 'unregister_feed') ); 180 } 181 } 182 183 function get_message($message_slug) { 184 $text_domain = 'mb_globalfeed'; 185 186 switch ($message_slug) { 187 case 'rss_parsing_error': 188 return __('GlobalFeed RSS has encountered a problem parsing an RSS feed. Please report the error using the bug reports feature and detail the feed source.', $text_domain); 189 case 'feed_not_configured': 190 return __('GlobalFeed RSS has encountered a problem updating an RSS feed. Please visit the GlobalFeed RSS configuration for more information.', $text_domain); 191 default: 192 return 'GlobalFeed RSS error 404: Unknown message slug.'; 179 193 } 180 194 } … … 495 509 496 510 // If the request did not succeed, log the error and continue. 497 if ( is_wp_error($request) ) {511 if ( is_wp_error($request) ) { 498 512 $feed_options['errors'][] = array( 499 513 'error' => 'Error updating feed: ' . (empty($feed->title)) ? $feed_url : $feed->title, … … 502 516 'time' => time(), 503 517 ); 518 519 $this->add_alert('feed_not_configured', $this->get_message('feed_not_configured'), true, false); 504 520 continue; 505 521 } … … 520 536 'time' => time(), 521 537 ); 538 539 $this->add_alert('rss_parsing_error', $this->get_message('rss_parsing_error'), true, false); 522 540 continue; 523 541 } … … 525 543 // Loop through the updates and convert to WP Posts. 526 544 foreach ( $updates->item as $update ) { 527 528 545 // Check if the feed date is less than the processed date and that were supposed to check that. 529 546 if ( strtotime( (string) trim($update->pubDate) ) < $feed['last_update'] && $feed['enforce_dates'] ) … … 623 640 624 641 // Save all of the feed items. 625 626 //$globalfeed->print_debug_info( 627 $globalfeed->save_feed_items( $this->feed_slug, $feed_items ); 628 //); 642 $globalfeed->save_feed_items( $this->feed_slug, $feed_items ); 629 643 630 644 return count( $feed_items ); … … 638 652 * @return str 639 653 */ 640 function get_xml_attr( $obj, $attr ){654 private function get_xml_attr( $obj, $attr ){ 641 655 $atts = $obj->attributes(); 642 656 return (string) trim( $atts[$attr] ); -
globalfeed/trunk/mb_globalfeed.php
r711609 r790780 55 55 'notification', 56 56 'debug', 57 'mb_facebook', 57 'facebook_connec', 58 'twitter_connect', 58 59 'register_feeds', 59 60 'request_modify', … … 714 715 // For tags and categories, make the tag/category number the array key 715 716 $cats = array(); 716 if ( $current_page_info[ 'category' ] ) 717 if ( $current_page_info[ 'category' ] ) { 717 718 foreach ($current_page_info[ 'category' ] as $category) { 718 719 $cats[ $category ] = $category; 719 720 }; 721 } 720 722 721 723 $tags = array(); … … 1122 1124 * @return bool True if activated, false if not. 1123 1125 */ 1124 function feed_activated( $feed_slug ) {1126 function feed_activated( $feed_slug ) { 1125 1127 return isset( $this->registered_feeds[ $this->get_shortened_feed_slug($feed_slug) ] ); 1126 1128 } … … 1133 1135 * @return str|bool The shortened feed slug, or false if the feed is not registered. 1134 1136 */ 1135 function get_feed_options( $feed_slug ) {1137 function get_feed_options( $feed_slug ) { 1136 1138 return $this->feed_activated( $feed_slug ) ? 1137 1139 $this->registered_feeds[ $this->get_shortened_feed_slug($feed_slug) ] : false; -
globalfeed/trunk/readme.txt
r593074 r790780 5 5 Requires at least: 3.3 6 6 Tested up to: 3.4.1 7 Stable tag: 0.1. 37 Stable tag: 0.1.4 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 92 92 == Changelog == 93 93 94 = 0.1.4 = 95 - Fixed a bug in MB Facebook where Facebook pages could not be loaded. 96 - Fixed a jQuery parsing bug, where geological information in a jQuery stream would corrupt the data. 97 - Upgraded MB Twitter for API 1.1 compatibility and fixed an authorization bug. 98 - Rerouted Facebook and Twitter object requests through GlobalFeed to remove the need for a cross-domain request. 99 94 100 = 0.1.3 = 95 101 - Added GlobalFeed option to open GlobalFeed-generated links in a new window. … … 152 158 = 0.5 = 153 159 * Better support for 3rd party feeds 154 155 = Winter Season 2012 =156 Numerous Social Media APIs require applications to authenticate in order to fetch user157 data, such as Facebook, Google+ and coming March 2013: Twitter. At GlobalFeed, we believe that158 the need for users to go and create their own applications on these services in order to159 get application IDs and secrets is not a positive user experience. That is why GlobalFeed160 will be rolling out a webservice based off of MichaelBlouin.ca that will be responsible161 for fetching data directly from Social Media sources and will act as a middleman,162 making it infinitely quicker and easier for users to access their social media content163 from their blog. All users will have to do is give GlobalFeed permission to read164 their streams, and GlobalFeed will do the rest.165 166 For privacy conscious users who would prefer GlobalFeed not have access to their information,167 the GlobalFeed plugin will still offer users the option of inputting their own application168 information and having their WordPress blog fetch data directly from these services instead169 of using the GlobalFeed service.170 171 If you have a positive or negative opinion or any concerns about this change, please let us know172 on our Feature Requests page at: http://globalfeed.michaelblouin.ca/feature-requests
Note: See TracChangeset
for help on using the changeset viewer.