https://github.com/dspacelabs/shopify-client
Shopify PHP SDK
https://github.com/dspacelabs/shopify-client
php php-client shopify shopify-client
Last synced: about 1 month ago
JSON representation
Shopify PHP SDK
- Host: GitHub
- URL: https://github.com/dspacelabs/shopify-client
- Owner: dSpaceLabs
- License: mit
- Created: 2015-12-11T04:02:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-11T00:01:12.000Z (almost 8 years ago)
- Last Synced: 2023-08-21T09:49:10.109Z (over 1 year ago)
- Topics: php, php-client, shopify, shopify-client
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Shopify Client [](https://travis-ci.org/dSpaceLabs/Shopify)
==============PHP Shopify Client for easy integration into your projects and apps
- PHP Client for working with the Shopify API
- Source code is well documented
- Heavily tested and maintained
- Production Shopify Apps are using
- Maintain a high standard of code quality [](https://codeclimate.com/github/dSpaceLabs/Shopify)
- Private apps support## Requirements
- PHP cURL extension
- PHP >= 5.4
- See [Travis CI](https://travis-ci.org/dSpaceLabs/Shopify) for builds of each
version
- [Shopify Partner Account](https://developers.shopify.com/?ref=dspace)## Installation
```bash
composer require "dspacelabs/shopify:^1.0@dev"
```## Usage
### Redirect user to Shopify to authorize your application
```php
setShop('example.myshopify.com');
// This is the same thing as doing the entire domain
//$client->setShop('example');// List of scopes can be in the Client class
$client->setScopes(
array(
Client::SCOPE_WRITE_CUSTOMERS,
Client::SCOPE_READ_CUSTOMERS
)
);$nonce = time(); // Save in session, used in callback action
$authorizationUri = $client->getAuthorizationUrl('https://example.com/shopify/callback', $nonce);
// redirect user to $authorizationUri
```### Shopify redirects user back to your callback url
```php
has('nonce')) {
throw new AccessedDeniedError();
}$client = new Client($accessKey, $secretKey);
$client->setShop('example.myshopify.com');// `isValid` takes array of query parameters, think $_GET, $_POST, etc.
// This example is using a Request object from the symfony/http-foundation
// library
if (!$client->isValid($request->query->all())) {
throw new \AccessDeniedError();
}// Persist access token in database
$accessToken = $client->getAccessToken($request->query->get('code'));
```### Making requests to Shopify
```php
setShop('example.myshopify.com')
->setAccessToken($accessToken);$result = $client->call('GET', '/admin/customers.json');
// Process $result
```### Recurring application charges
@todo
### Creating and using webhooks
@todo
### Private Apps
See [Generate private app credentials](https://help.shopify.com/api/guides/api-credentials#generate-private-app-credentials).
```php
setPrivate(true)
->setShop('example.myshopify.com');
```## Applications using this library
- [lvl67](http://www.lvl67.com)