Last active
April 19, 2018 01:03
-
-
Save crazytonyi/d5ba8033cc308612c92c5dd7cf9fb60c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$client = new \GuzzleHttp\Client(); | |
$request = $client->createRequest('GET', 'https://beta.check-mot.service.gov.uk'); | |
$request->addHeader('x-api-key', 'MY API KEY'); | |
try { | |
$resp = $client->send($request); | |
} catch (GuzzleHttp\Exception\ClientException $e) { | |
$resp = $e->getResponse(); | |
} | |
echo $resp; |
What version of Guzzle are you testing this with?
Still the same issue? Could it be due to my pc settings or operating system?
6 I believe
It's because you are using createRequest
, which Guzzle 6 isn't friendly with. This gist works fine in Guzzle 5.3, but has the same error you are seeing when run on Guzzle 6. Check out this gist, which I wrote for Guzzle 6 (and basically is the same as your first example in your SO question, but trimmed down) : https://gist.github.com/crazytonyi/10222135ab7b4d9407d2103130a94cfa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Anthony Im still getting the Type error: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given, called in /home/web/APIprojecttest/project/vendor/guzzlehttp/guzzle/src/Client.php on line 89, Could it be im missing a package or something?