Working multi tokens with nicknames

This commit is contained in:
Justin Foell
2017-07-21 16:12:15 -05:00
parent 6c15a669f1
commit 8fc5ea3407
4 changed files with 173 additions and 61 deletions
+10 -7
View File
@@ -9,7 +9,7 @@ class WPStrava_API {
//const STRAVA_V2_API = 'http://www.strava.com/api/v2/'; //rides/:ride_id/map_details
const STRAVA_V3_API = 'https://www.strava.com/api/v3/';
public function __construct( $access_token ) {
public function __construct( $access_token = null ) {
$this->access_token = $access_token;
}
@@ -19,11 +19,13 @@ class WPStrava_API {
$args = array(
'body' => http_build_query( $data ),
'sslverify' => false,
'headers' => array(
'Authorization' => 'Bearer ' . $this->access_token,
)
'headers' => array(),
);
if ( $this->access_token ) {
$args['headers']['Authorization'] = 'Bearer ' . $this->access_token;
}
$response = wp_remote_post( $url . $uri, $args );
if ( is_wp_error( $response ) )
@@ -55,10 +57,11 @@ class WPStrava_API {
$url = add_query_arg( $args, $url );
$get_args = array(
'headers' => array(
'Authorization' => 'Bearer ' . $this->access_token,
)
'headers' => array(),
);
if ( $this->access_token ) {
$get_args['headers']['Authorization'] = 'Bearer ' . $this->access_token;
}
$response = wp_remote_get( $url, $get_args );