oauth_connect

The All In One SEO Pack oauth connect function.

Description

(string) oauth_connect( (int) $count = 0 ); 

Returns (string)

Parameters (1)

0. $count — Optional. (int)
The count.

Usage

  1. if ( !function_exists( 'oauth_connect' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'all-in-one-seo-pack/inc/deprecated.php'; 
  3.  
  4. // The count. 
  5. $count = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = oauth_connect($count); 
  9.  

Defined (1)

The function is defined in the following location(s).

/inc/deprecated.php  
  1. function oauth_connect( $count = 0 ) { 
  2. global $aiosp_activation; 
  3. if ( ! class_exists( 'OAuthConsumer' ) ) { 
  4. require_once( AIOSEOP_PLUGIN_DIR . 'inc/extlib/OAuth.php' ); 
  5. $url = ''; 
  6. $callback_url = null; 
  7. $consumer_key = 'anonymous'; 
  8. $consumer_secret = 'anonymous'; 
  9. $oauth_request_token = 'https://www.google.com/accounts/OAuthGetRequestToken'; 
  10. $oauth_authorize = 'https://www.google.com/accounts/OAuthAuthorizeToken'; 
  11. $oauth_access_token = 'https://www.google.com/accounts/OAuthGetAccessToken'; 
  12. if ( $aiosp_activation ) { 
  13. $oauth_current = false; 
  14. } else { 
  15. $oauth_current = get_transient( 'aioseop_oauth_current' ); 
  16. if ( ! empty( $this->token ) && ( $this->token != 'anonymous' ) && $oauth_current ) { 
  17. return $oauth_authorize . '?oauth_token=' . $this->token; 
  18. } else { 
  19. set_transient( 'aioseop_oauth_current', 1, 3600 ); 
  20. unset( $this->token ); 
  21. unset( $this->secret ); 
  22. $args = array( 
  23. 'scope' => 'https://www.google.com/analytics/feeds/',  
  24. 'xoauth_displayname' => AIOSEOP_PLUGIN_NAME . ' ' . __( 'Google Analytics', 'all-in-one-seo-pack' ) 
  25. ); 
  26. if ( AIOSEOPPRO ) { 
  27. $req_req = $this->oauth_get_creds( $oauth_request_token, null, $args, admin_url( 'admin.php?page=all-in-one-seo-pack-pro/aioseop_class.php' ) ); 
  28. } else { 
  29. $req_req = $this->oauth_get_creds( $oauth_request_token, null, $args, admin_url( 'admin.php?page=all-in-one-seo-pack/aioseop_class.php' ) ); 
  30. $reqData = wp_remote_get( $req_req->to_url() ); 
  31. $reqOAuthData = OAuthUtil::parse_parameters( wp_remote_retrieve_body( $reqData ) ); 
  32. if ( ! empty( $reqOAuthData['oauth_token'] ) ) { 
  33. $this->token = $reqOAuthData['oauth_token']; 
  34. if ( ! empty( $reqOAuthData['oauth_token_secret'] ) ) { 
  35. $this->secret = $reqOAuthData['oauth_token_secret']; 
  36. if ( ! empty( $this->token ) && ( $this->token != 'anonymous' ) && $oauth_current ) { 
  37. $url = $oauth_authorize . "?oauth_token={$this->token}"; 
  38. } else { 
  39. if ( ! $count ) { 
  40. return $this->oauth_connect( 1 ); 
  41.  
  42. return $url;