You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+113-9Lines changed: 113 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# SHOPIFY API PHP SDK
2
-
PHP SDK helps to connect with shopify [Custom App](https://shopify.dev/concepts/apps#custom-apps), [Public App](https://shopify.dev/concepts/apps#public-apps) and [Private App](https://shopify.dev/concepts/apps#private-apps) using [RESTApi](https://shopify.dev/docs/admin-api/rest/reference) and [Graphql](https://shopify.dev/docs/admin-api/graphql/reference).
2
+
PHP SDK helps to connect with shopify [Custom App](https://shopify.dev/concepts/apps#custom-apps), [Public App](https://shopify.dev/concepts/apps#public-apps) and [Private App](https://shopify.dev/concepts/apps#private-apps) using [REST Api](https://shopify.dev/docs/admin-api/rest/reference) and [Graphql](https://shopify.dev/docs/admin-api/graphql/reference).
3
3
* Call GET, POST, PUT and DELETE RestApi method.
4
4
* Process GraphQL Admin API for [Query root](https://shopify.dev/docs/admin-api/graphql/reference/queryroot) and [Mutations](https://shopify.dev/docs/admin-api/graphql/reference/mutation).
5
5
* Queryroot is used to get resources and mutations is used to update resources (products/orders/customers).
@@ -20,7 +20,7 @@ PHP SDK helps to connect with shopify [Custom App](https://shopify.dev/concepts/
20
20
## Getting started
21
21
### Initialize the client
22
22
#### 1. For Private App
23
-
* To create instance of `Client` class, you need `shop`, `api_key`, `password` of private app, `api_params` is an array to pass api version with `YYYY-DD/unstable` format otherwise, Api latest version will be assigned.
23
+
* To create instance of `Client` class, need `shop`, `api_key`, `password` of private app, `api_params` is an array to pass api version with `YYYY-DD/unstable` format otherwise, Api latest version will be assigned.
24
24
25
25
```
26
26
<?php
@@ -30,18 +30,63 @@ PHP SDK helps to connect with shopify [Custom App](https://shopify.dev/concepts/
30
30
$api_params['version'] = '2019-10';
31
31
$client = new Shopify\PrivateApp($shop, $api_key, $password, $api_params);
32
32
```
33
-
#### 2. For Public/Custom App (under development)
34
-
* To create instance of `Client` class, you need `shop`, `api_key`, `api_secret_key` of private app, `api_params` is an array to pass api version with `YYYY-DD/unstable` format otherwise, Api latest version will be assigned.
33
+
#### 2. For Public App
34
+
* To create instance of `Client` class, need `shop`, `api_key`, `api_secret_key` of public app.
35
35
36
36
```
37
37
<?php
38
38
require(__DIR__ . '/../vendor/autoload.php');
39
39
use Shopify\PuplicApp;
40
40
41
41
$api_params['version'] = '2019-10';
42
-
$client = new Shopify\PrivateApp($shop, $api_key, $api_secret_key, $api_params);
42
+
$client = new Shopify\PublicApp($shop, $api_key, $api_secret_key, $api_params);
43
43
```
44
+
* Prepare authorise url to install public app and get `access_token`
45
+
```
46
+
if(isset($_GET['code']))
47
+
{
48
+
//get access_token after authorization of public app
Note: Oauth process is similar to public app. To authenticate with Shopify by using a custom app, you need to generate an [installation link](https://shopify.dev/tutorials/authenticate-a-custom-app-with-oauth#create-a-custom-app-and-generate-an-installation-link) from your Partner Dashboard.
68
+
* To create instance of `Client` class, need `shop`, `api_key`, `api_secret_key` of custom app.
69
+
70
+
```
71
+
<?php
72
+
require(__DIR__ . '/../vendor/autoload.php');
73
+
use Shopify\PuplicApp;
74
+
75
+
$api_params['version'] = '2019-10';
76
+
$client = new Shopify\PublicApp($shop, $api_key, $api_secret_key, $api_params);
77
+
```
78
+
* Copy link from `Merchant install link` section in Custom App and run in browser then it redirect to your url provied provided while creating custom app.
79
+
```
80
+
if(isset($_GET['code']))
81
+
{
82
+
//get access_token after authorization of public app
If you continue repeating this step with the cursor value of the last product in each response you get until your response is empty. So need to check `cursor` index available in last array of `$response` then repeat call by adding cursor value with `after` attribute in products field.
0 commit comments