summaryrefslogtreecommitdiff
path: root/Readme.md
blob: f3fc3b70f12cd9300f6e1dd36766b5b350f515fc (plain)
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
# guzzle-cardmarket-api-middleware

to use with the [Cardmarket API](https://api.cardmarket.com/ws/documentation)

## Installation
```
composer require drogueronin/guzzle-cardmarket-api-middleware
```

## How to use

```php
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use CardmarketApi\OAuthMiddleware;

// Create default HandlerStack
$stack = HandlerStack::create();

// Add this middleware to the top with `push`
$stack->push(new OAuthMiddleware(), 'oauth');

// Initialize the client with the handler option and cardmarket oauth data
$client = new Client([
    'handler' => $stack,
    'base_uri' => 'https://api.cardmarket.com/ws/v2.0/output.json/',
    'cardmarket' => [
        'app_token' => 'your_app_token',
        'app_secret' => 'your_app_secret',
        'access_token' => 'your_access_token',
        'access_token_secret' => 'your_access_token_secret',
    ],
]);

// Request a resource
$response = $client->get('account');
```