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
+117-3Lines changed: 117 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Add `"rocket-code/shopify": "~1.0"` in your "require" object. With a blank Larav
15
15
}
16
16
```
17
17
####Add the Service Provider
18
-
In `app/config/app.php`, add `'RocketCode\Shopify\ShopifyServiceProvider'` to the end of the `'providers'` array.
18
+
In `app/config/app.php`, add `RocketCode\Shopify\ShopifyServiceProvider` to the end of the `providers` array.
19
19
20
20
##Setting Up
21
21
To begin, use `App::make()` to grab an instance of the `API` class.
@@ -60,7 +60,9 @@ Once the user accesses the Install URL and clicks the Install button, they will
60
60
After setting up with at least `SHOP_DOMAIN`, `API_KEY`, & `API_SECRET`, call `getAccessToken()` with the code passed back in the URL. Laravel makes this easy:
`verifyRequest()` throws an Exception in two cases: If the timestamp generated by Shopify and your server are more than an hour apart, or if the argument passed is not an array or URL-encoded string of key/values.
105
+
`verifyRequest()` returns `TRUE` when data is valid, otherwise `FALSE`. It throws an Exception in two cases: If the timestamp generated by Shopify and your server are more than an hour apart, or if the argument passed is not an array or URL-encoded string of key/values.
106
+
107
+
If you would like to skip the timestamp check (not recommended unless you cannot correct your server's time), you can pass `TRUE` as a second argument to `verifyRequest()` and timestamps will be ignored:
108
+
109
+
```
110
+
$verify = $sh->verifyRequest(Input::all(), TRUE);
111
+
```
112
+
113
+
## Private Apps
114
+
The API Wrapper does not distinguish between private and public apps. In order to utilize it with a private app, set up everything as you normally would, replacing the OAuth Access Token with the private app's Password.
115
+
116
+
##Calling the API
117
+
Once set up, simply pass the data you need to the `call()` method.
118
+
119
+
```
120
+
$result = $sh->call($args);
121
+
```
122
+
123
+
####`call()` Parameters
124
+
The parameters listed below allow you to set required values for an API call as well as override additional default values.
125
+
126
+
*`METHOD`: The HTTP method to use for your API call. Different endpoints require different methods.
127
+
* Default: `GET`
128
+
*`URL`: The URL of the API Endpoint to call.
129
+
* Default: `/` (not an actual endpoint)
130
+
*`HEADERS`: An array of additional Headers to be sent
131
+
* Default: Empty `array()`. Headers that are automatically sent include:
132
+
* Accept
133
+
* Content-Type
134
+
* charset
135
+
* X-Shopify-Access-Token
136
+
*`CHARSET`: Change the charset if necessary
137
+
* Default: `UTF-8`
138
+
*`DATA`: An array of data being sent with the call. For example, `$args['DATA'] = array('product' => $product);` For an [`/admin/products.json`](http://docs.shopify.com/api/product#create) product creation `POST`.
139
+
* Default: Empty `array()`
140
+
*`RETURNARRAY`: Set this to `TRUE` to return data in `array()` format. `FALSE` will return a `stdClass` object.
141
+
* Default: `FALSE`
142
+
*`ALLDATA`: Set this to `TRUE` if you would like all error and cURL info returned along with your API data (good for debugging). Data will be available in `$result->_ERROR` and `$result->_INFO`, or `$result['_ERROR']` and `$result['_INFO']`, depending if you are having it returned as an object or array. Recommended to be set to `FALSE` in production.
143
+
* Default: `FALSE`
144
+
*`FAILONERROR`: The value passed to cURL's [CURLOPT_FAILONERROR](http://php.net/manual/en/function.curl-setopt.php) setting. `TRUE` will cause the API Wrapper to throw an Exception if the HTTP code is >= `400`. `FALSE` in combination with `ALLDATA` set to `TRUE` will give you more debug information.
145
+
* Default: `TRUE`
146
+
147
+
148
+
##Some Examples
149
+
Assume that `$sh` has already been set up as documented above.
0 commit comments