colorfield / mastodon-api-php

PHP wrapper for the Mastodon API.
Apache License 2.0
28 stars 5 forks source link

Respect the api version that is being set in the ConfigurationVO #12

Open skoop opened 1 month ago

skoop commented 1 month ago

What happened?

I was creating a ConfigurationVO object and I was setting the $apiVersion parameter to v2. When I then used the MastodonAPI object that I can created using the ConfigurationVO object, when I called (in my case) the /search endpoint, I got a 404 error from the API, because it was trying to call /api/v1/search. It did not respect the v2 I had set because the code was using the ConfigurationVO::API_VERSION constant, which is set to v1.

The solution

Instead of using the constant from the ConfigurationVO class, I use the $apiVersion property of the $this->config instead of the VO. Now, when I call the getPublicData('/search'), it respects the version and calls the v2 API.