Shopio Rest Api Client
, (*1)
Installation
$ composer require "shopiolabs/shopioapi":"dev-master"
Getting Started
Authentication Example
getAccessToken($_GET['code'], $scope, $_SESSION['page_url']);
//Save access_token
} elseif (isset($_POST['shop'])) {
// get the URL to the current page
$pageURL = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
$pageURL = $_SERVER["SERVER_PORT"] != "80" ? $pageURL.":".$_SERVER["SERVER_PORT"] : $pageURL;
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER['SCRIPT_NAME'];
$_SESSION['shop'] = $_POST['shop'];
$_SESSION['page_url'] = $pageURL;
$shopioAuthClient = new ShopioAuthClient($_SESSION['shop'], $apiKey, $secret);
$authorizeUrl = $shopioAuthClient->getAuthorizeUrl($scope, $pageURL);
header("Location: $authorizeUrl");exit;
}
?>
Client Usage Example
$accessToken = 'YOUR_ACCESS_TOKEN_HERE';
$shopioClient = new ShopioClient('example.myshopio.com', $accessToken);
//List brands
$brands = $shopioClient->call('brands', 'GET');
//Get a single brand
$brand = $shopioClient->call('brands/'.$brands[0]['id'], 'GET');
//Create a new brand
$data = [
'title' => 'Test',
'status' => '1'
];
$newBrand = $shopioClient->call('brands', 'POST', $data);
//Update a brand
$data = [
'title' => 'test2',
];
$updatedBrand = $shopioClient->call('brands/'.$newBrand['id'], 'PUT', $data);
//Delete a brand
$shopioClient->call('brands/'.$updatedBrand['id'], 'DELETE');
````
## Tests
Run tests with the following command in root directory.
```bash
$ ./vendor/bin/phpunit
Contributing
Please see CONTRIBUTING for details., (*3)
License
The MIT License (MIT). Please see License File for more information., (*4)