Changeset 9107 for sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-meetup-client.php
- Timestamp:
- 08/17/2019 12:35:04 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-meetup-client.php
r9105 r9107 73 73 ); 74 74 75 $this->debug = $settings['debug']; 76 77 if ( $this->debug ) { 78 self::cli_message( "Meetup Client debug is on. Results will be truncated." ); 79 } 80 75 81 $this->oauth_client = new Meetup_OAuth2_Client; 76 $this->debug = $settings['debug']; 77 78 if ( $this->debug ) { 79 self::cli_message( "Meetup Client debug is ON. Results will be truncated." ); 82 83 if ( ! empty( $this->oauth_client->error->get_error_messages() ) ) { 84 $this->error = $this->merge_errors( $this->error, $this->oauth_client->error ); 85 } 86 87 add_action( 'api_client_tenacious_remote_request_attempt', array( $this, 'maybe_reset_oauth_token' ) ); 88 } 89 90 /** 91 * Attempt to fix authorization errors before they permanently fail. 92 * 93 * Hooked to `api_client_tenacious_remote_request_attempt` so that a request that has failed due to an invalid 94 * oauth token can be retried after resetting the token. 95 * 96 * @param array $response 97 * 98 * @return void 99 */ 100 public function maybe_reset_oauth_token( $response ) { 101 $code = wp_remote_retrieve_response_code( $response ); 102 $body = json_decode( wp_remote_retrieve_body( $response ), true ); 103 104 if ( 400 === $code && ! empty( $body['error'] ) && 'invalid_grant' === $body['error'] ) { 105 $this->oauth_client->reset_oauth_token(); 106 107 if ( ! empty( $this->oauth_client->error->get_error_messages() ) ) { 108 $this->error = $this->merge_errors( $this->error, $this->oauth_client->error ); 109 } 110 111 // Reset the request headers, so that they include the new oauth token. 112 $this->current_request_args = $this->get_request_args(); 80 113 } 81 114 } … … 123 156 $request_url = $this->get_next_url( $response ); 124 157 } else { 125 $this->handle_error_response( $response );158 $this->handle_error_response( $response, $request_url ); 126 159 break; 127 160 } … … 168 201 } 169 202 } else { 170 $this->handle_error_response( $response );203 $this->handle_error_response( $response, $request_url ); 171 204 } 172 205 … … 295 328 ); 296 329 } 330 } elseif ( isset( $data['error'], $data['error_description'] ) ) { 331 $this->error->add( 332 $data['error'], 333 $data['error_description'] 334 ); 297 335 } elseif ( isset( $data['code'] ) && isset( $data['details'] ) ) { 298 336 $this->error->add(
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)