An object-oriented approach towards using the Shopify API. This repos is a work-in-progress and not production ready.
Please note: the old version (v0.9) using Guzzle 3.9 is maintained here
$ composer require dan/shopify-api v1.*
// Assumes setup of client with access token.
$api = Dan\Shopify\Shopify::make($shop, $token);
$api->orders->find($order_id = 123); // returns Dan\Shopify/Models/Order
// Alternatively, we may call methods on the API object.
$api->orders->get([], $order_id = 123); // returns array
See Facade usages for other methods available.
In your config/app.php
Dan\Shopify\Integrations\Laravel\ShopifyServiceProvider::class,
'Shopify' => Dan\Shopify\Integrations\Laravel\ShopifyFacade::class,
SHOPIFY_DOMAIN=your-shop-name.myshopify.com
SHOPIFY_TOKEN=your-token-here
It will be instantiated with your shop and token you setup in
config/shopify.php
or
Shopify::getAppInstallResponse(
'your_app_client_id',
'your_app_client_secret',
'shop_from_request',
'code_from_request'
);
// returns (object) ['access_token' => '...', 'scopes' => '...']
Dan\Shopify\Util::validAppHmac(
'hmac_from_request',
'your_app_client_secret',
['shop' => '...', 'timestamp' => '...', ...]
);
Dan\Shopify\Util::validWebhookHmac(
'hmac_from_request',
'your_app_client_secret',
file_get_contents('php://input')
);
- Artisan Command to create token
MIT.