diff --git a/src/APnutI.php b/src/APnutI.php index 91403de..ea80e5a 100644 --- a/src/APnutI.php +++ b/src/APnutI.php @@ -210,13 +210,17 @@ class APnutI curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } if ($method === 'GET' && isset($parameters['access_token'])) { + $this->logger->info("Using provided token for auth"); $headers[] = 'Authorization: Bearer '.$params['access_token']; } elseif (!empty($this->access_token)) { + $this->logger->info("Using access token for auth"); $headers[] = 'Authorization: Bearer '.$this->access_token; } elseif (!empty($this->server_token)) { $use_server_token = true; $this->logger->info("Using server token for auth"); $headers[] = 'Authorization: Bearer '.$this->server_token; + } else { + $this->logger->info("Using no auth"); } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); @@ -698,11 +702,20 @@ class APnutI return new Channel($this->get('/channels/'.$channel_id, $parameters), $this); } - public function getSubscribedChannel(): array + public function getSubscribedChannels(bool $include_pms = true, bool $include_channels = true): array { # Always include channel raw, it contains the channel name + $channel_types = []; + if ($include_pms) { + $channel_types[] = 'io.pnut.core.pm'; + } + if ($include_channels) { + $channel_types[] = 'io.pnut.core.chat'; + } + $parameters = [ - 'include_channel_raw' => true + 'include_channel_raw' => true, + 'channel_types' => implode(',', $channel_types) ]; $channels = []; $resp = $this->get('/users/me/channels/subscribed', $parameters); @@ -765,4 +778,9 @@ class APnutI throw new PnutException("Error retrieving app access token: ".json_encode($resp)); } } + + public function getAccessToken(): string + { + return $this->access_token; + } }