├── index.html
├── composer.json
├── conf.php
├── README.md
├── get_shop.php
├── get_products.php
└── create_product.php
/index.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "minimum-stability": "dev",
3 | "require": {
4 | "php": ">=5.3.0",
5 | "phpish/shopify": "dev-master"
6 | }
7 | }
--------------------------------------------------------------------------------
/conf.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 1. Clone the repo and get dependencies via composer
2 |
3 | ```
4 | git clone --depth 1 --branch master https://github.com/phpish/shopify_private_app-skeleton.git new_prj
5 | cd new_prj
6 | rm -rf .git
7 | rm README.md
8 | curl -sS https://getcomposer.org/installer | php
9 | php composer.phar install
10 | ```
11 |
12 | 2. [Create a private app](http://docs.shopify.com/api/authentication/creating-a-private-app).
13 | 3. Update conf.php with the private app's credentials.
14 | 4. Check out the .php files and see how they work. (e.g., http://path-to-new_prj/get_shop.php)
--------------------------------------------------------------------------------
/get_shop.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | session_start();
4 |
5 | require __DIR__.'/vendor/autoload.php';
6 | use phpish\shopify;
7 |
8 | require __DIR__.'/conf.php';
9 |
10 | $shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);
11 |
12 | try
13 | {
14 | # Making an API request can throw an exception
15 | $shop = $shopify('GET /admin/shop.json');
16 | print_r($shop);
17 | }
18 | catch (shopify\ApiException $e)
19 | {
20 | # HTTP status code was >= 400 or response contained the key 'errors'
21 | echo $e;
22 | print_R($e->getRequest());
23 | print_R($e->getResponse());
24 | }
25 | catch (shopify\CurlException $e)
26 | {
27 | # cURL error
28 | echo $e;
29 | print_R($e->getRequest());
30 | print_R($e->getResponse());
31 | }
32 |
33 | ?>
--------------------------------------------------------------------------------
/get_products.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | session_start();
4 |
5 | require __DIR__.'/vendor/autoload.php';
6 | use phpish\shopify;
7 |
8 | require __DIR__.'/conf.php';
9 |
10 | $shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);
11 |
12 | try
13 | {
14 | # Making an API request can throw an exception
15 | $products = $shopify('GET /admin/products.json', array('published_status'=>'published'));
16 | print_r($products);
17 | }
18 | catch (shopify\ApiException $e)
19 | {
20 | # HTTP status code was >= 400 or response contained the key 'errors'
21 | echo $e;
22 | print_R($e->getRequest());
23 | print_R($e->getResponse());
24 | }
25 | catch (shopify\CurlException $e)
26 | {
27 | # cURL error
28 | echo $e;
29 | print_R($e->getRequest());
30 | print_R($e->getResponse());
31 | }
32 |
33 | ?>
--------------------------------------------------------------------------------
/create_product.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | session_start();
4 |
5 | require __DIR__.'/vendor/autoload.php';
6 | use phpish\shopify;
7 |
8 | require __DIR__.'/conf.php';
9 |
10 | $shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);
11 |
12 | try
13 | {
14 | # Making an API request can throw an exception
15 | $product = $shopify('POST /admin/products.json', array(), array
16 | (
17 | 'product' => array
18 | (
19 | "title" => "Burton Custom Freestlye 151",
20 | "body_html" => "Good snowboard!",
21 | "vendor" => "Burton",
22 | "product_type" => "Snowboard",
23 | "variants" => array
24 | (
25 | array
26 | (
27 | "option1" => "First",
28 | "price" => "10.00",
29 | "sku" => 123,
30 | ),
31 | array (
32 | "option1" => "Second",
33 | "price" => "20.00",
34 | "sku" => "123"
35 | )
36 | )
37 | )
38 | ));
39 |
40 | print_r($product);
41 | }
42 | catch (shopify\ApiException $e)
43 | {
44 | # HTTP status code was >= 400 or response contained the key 'errors'
45 | echo $e;
46 | print_R($e->getRequest());
47 | print_R($e->getResponse());
48 | }
49 | catch (shopify\CurlException $e)
50 | {
51 | # cURL error
52 | echo $e;
53 | print_R($e->getRequest());
54 | print_R($e->getResponse());
55 | }
56 |
57 | ?>
--------------------------------------------------------------------------------