Skip to content

Instantly share code, notes, and snippets.

@crazytonyi
Last active April 19, 2018 19:01
Show Gist options
  • Save crazytonyi/10222135ab7b4d9407d2103130a94cfa to your computer and use it in GitHub Desktop.
Save crazytonyi/10222135ab7b4d9407d2103130a94cfa to your computer and use it in GitHub Desktop.
<?php
$client = new \GuzzleHttp\Client();
$headers = ['x-api-key' => 'MY API KEY'];
$options = [
'headers' => ['x-api-key' => 'MY API KEY'],
'debug' => true,
];
try {
$resp = $client->request('GET', 'https://beta.check-mot.service.gov.uk',$options);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$resp = $e->getResponse();
}
echo $resp->getBody();
@crazytonyi
Copy link
Author

Does that also work if you update the URL for the guzzle request?

@ZalumsArtis
Copy link

Would I need to update the actual url within controller?

@crazytonyi
Copy link
Author

The URL in the request.

@ZalumsArtis
Copy link

By using function?

public function apitest(){

$client = new \GuzzleHttp\Client();
$headers = ['x-api-key' => 'Key here'];

$options = [
'headers' => ['x-api-key' => 'Key here'],
'debug' => true,
];
try {
$resp = $client->request('GET', 'https://beta.check-mot.service.gov.uk/trade/vehicles/mot-tests\?registration=XX10ABC
',$options);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$resp = $e->getResponse();
}
echo $resp->getBody();

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment