-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathguzzle_example.php
39 lines (31 loc) · 1.01 KB
/
guzzle_example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
use GuzzleHttp\{Client, HandlerStack, RequestOptions, Subscriber\Oauth\Oauth1};
require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/configs.php';
$stack = HandlerStack::create();
$middleware = new Oauth1([
'consumer_key' => NS_CONSUMER_KEY,
'consumer_secret' => NS_CONSUMER_SECRET,
'signature_method' => Oauth1::SIGNATURE_METHOD_HMAC,
'token' => NS_TOKEN_ID,
'token_secret' => NS_TOKEN_SECRET,
'realm' => NS_ACCOUNT,
]);
$stack->push($middleware);
$client = new Client([
'base_uri' => NS_HOST,
'handler' => $stack,
'auth' => 'oauth',
]);
try {
$response = $client->get('/services/rest/record/v1/metadata-catalog/customer', [
RequestOptions::HEADERS => [
'Content-Type' => 'application/json',
'Accept'=> 'application/schema+json',
]
]);
print_r(json_decode($response->getBody()->getContents(), true));
print('OK').PHP_EOL;
} catch (\GuzzleHttp\Exception\ClientException $exception) {
print('ERROR').PHP_EOL;
}