diff --git a/includes/counters/class-social-count-plus-facebook-counter.php b/includes/counters/class-social-count-plus-facebook-counter.php index 061d1dd..f54167d 100644 --- a/includes/counters/class-social-count-plus-facebook-counter.php +++ b/includes/counters/class-social-count-plus-facebook-counter.php @@ -57,7 +57,8 @@ protected function get_access_token( $settings ) { if ( is_wp_error( $access_token ) || ( isset( $access_token['response']['code'] ) && 200 != $access_token['response']['code'] ) ) { return ''; } else { - return sanitize_text_field( $access_token['body'] ); + $access_token = json_decode( $access_token['body'], true ); + return sanitize_text_field( $access_token['access_token'] ); } } @@ -73,7 +74,7 @@ public function get_total( $settings, $cache ) { if ( $this->is_available( $settings ) ) { $access_token = $this->get_access_token( $settings ); $url = sprintf( - '%s%s?fields=fan_count&%s', + '%s%s?fields=fan_count&access_token=%s', $this->api_url . '/v2.7/', sanitize_text_field( $settings['facebook_id'] ), $access_token