get_credentials(); $this->key = $creds['key']; $this->secret = $creds['secret']; $this->consumer = new OAuthConsumer( $this->key, $this->secret, $this->callback_url ); $this->signature_method = new OAuthSignatureMethod_HMAC_SHA1; $this->authorization_header = 'Bearer'; // Oh, you $this->authorization_parameter = false; $this->set_endpoint( 'authorize', self::OAUTH_BASE . 'authorize', 'GET' ); $this->set_endpoint( 'access_token', self::OAUTH_BASE . 'token', 'POST' ); $this->set_endpoint( 'self', self::API_BASE . 'users/me/', 'GET' ); } function basic_ui_intro() { echo '

' . sprintf( __( 'To get started, register an OAuth client on Evenbrite. The most important setting is the OAuth Redirect URI, which should be set to %2$s. You can set the other values to whatever you like.', 'keyring' ), 'https://www.eventbrite.com/myaccount/apps/', Keyring_Util::admin_url( 'eventbrite', array( 'action' => 'verify' ) ) ) . '

'; echo '

' . __( "Once you've saved those changes, copy the CLIENT/APPLICATION KEY value into the API Key field, and the CLIENT SECRET value into the API Secret field and click save.", 'keyring' ) . '

'; } function build_token_meta( $token ) { $meta = array(); if ( empty( $token['access_token'] ) ) { return $meta; } $this->set_token( new Keyring_Access_Token( $this->get_name(), $token['access_token'], array() ) ); $response = $this->request( $this->self_url, array( 'method' => $this->self_method ) ); if ( !Keyring_Util::is_error( $response ) ) { $meta = array( 'user_id' => $response->id, 'name' => $response->name, ); } return apply_filters( 'keyring_access_token_meta', $meta, 'eventbrite', $token, $response, $this ); } function get_display( Keyring_Access_Token $token ) { return $token->get_meta( 'name' ); } function parse_response( $response ) { return json_decode( $response ); } function test_connection() { $res = $this->request( $this->self_url, array( 'method' => $this->self_method ) ); if ( !Keyring_Util::is_error( $res ) ) { return true; } return $res; } } add_action( 'keyring_load_services', array( 'Keyring_Service_Eventbrite', 'init' ) );