Can someone please explain why someone might use Guzzle to interact with a website’s API if the website provides a PHP API library? Are there benefits to using one or the other? And, if the website doesn’t yet have a PHP library, is Guzzle something that can be used to interact with any website’s API? And, I’m quite fearful that this is a super naive question: I’m just beginning to try and interact with website API’s and am not quite sure of the landscape.
Absolutely, the Guzzle library essentially provides a nicer interface for dealing with HTTP requests (rather than having to work with the underlying cURL module) and, as you say, can be used to work with any API.
The benefit of using a dedicated API client (if one exists) is that it usually abstracts a lot of the technical details of making API requests and parsing the responses. It may have methods for querying and fetching various resources without you having to manually construct the URLs and query strings. It might also handle authentication for you, so you end up having less boilerplate code to write.