FoxyCart / foxyclient-php

FoxyClient - a PHP Guzzle based API Client for working with the Foxy Hypermedia API
MIT License
9 stars 11 forks source link

Use PSR-7, PSR-17 and PSR-18 #15

Open theboxer opened 2 years ago

theboxer commented 2 years ago

Example init:

$config = [
    'use_sandbox' => false
];

$config['client_id'] = 'client_XXXXXXXXXXXXXXX';
$config['client_secret'] = 'XXXXXXXXXXXXXXX';
$config['refresh_token'] = 'XXXXXXXXXXXXXXX';

if (isset($_SESSION['access_token'])) {
    $config['access_token'] = $_SESSION['access_token'];
}
if (isset($_SESSION['access_token_expires'])) {
    $config['access_token_expires'] = $_SESSION['access_token_expires'];
}

$psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory();
$psr18Client = new \Buzz\Client\Curl($psr17Factory);

$fc = new FoxyClient($psr17Factory, $psr18Client, $config);
$res = $fc->get();