An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

Shopify Client [![Build Status](https://travis-ci.org/dSpaceLabs/Shopify.svg?branch=master)](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 [![Code Climate](https://codeclimate.com/github/dSpaceLabs/Shopify/badges/gpa.svg)](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)