Last active
April 19, 2018 01:03
-
-
Save crazytonyi/d5ba8033cc308612c92c5dd7cf9fb60c to your computer and use it in GitHub Desktop.
This file contains hidden or 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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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