Skip to content

Commit 9ae8623

Browse files
Merge pull request #1 from phpclassic/master
resync
2 parents 6c80502 + 00b6142 commit 9ae8623

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ composer require phpclassic/php-shopify
1414
PHPShopify uses curl extension for handling http calls. So you need to have the curl extension installed and enabled with PHP.
1515
>However if you prefer to use any other available package library for handling HTTP calls, you can easily do so by modifying 1 line in each of the `get()`, `post()`, `put()`, `delete()` methods in `PHPShopify\HttpRequestJson` class.
1616
17+
You can pass additional curl configuration to `ShopifySDK`
18+
```php
19+
$config = array(
20+
'ShopUrl' => 'yourshop.myshopify.com',
21+
'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
22+
'Password' => '***YOUR-PRIVATE-API-PASSWORD***',
23+
'Curl' => array(
24+
CURLOPT_TIMEOUT => 10,
25+
CURLOPT_FOLLOWLOCATION => true
26+
)
27+
);
28+
29+
PHPShopify\ShopifySDK::config($config);
30+
```
1731
## Usage
1832

1933
You can use PHPShopify in a pretty simple object oriented way.

lib/CurlRequest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ class CurlRequest
3535
*/
3636
public static $lastHttpResponseHeaders = array();
3737

38+
/**
39+
* Curl additional configuration
40+
*
41+
* @var array
42+
*/
43+
protected static $config = array();
44+
3845
/**
3946
* Initialize the curl resource
4047
*
@@ -57,6 +64,10 @@ protected static function init($url, $httpHeaders = array())
5764
curl_setopt($ch, CURLOPT_HEADER, true);
5865
curl_setopt($ch, CURLOPT_USERAGENT, 'PHPClassic/PHPShopify');
5966

67+
foreach (self::$config as $option => $value) {
68+
curl_setopt($ch, $option, $value);
69+
}
70+
6071
$headers = array();
6172
foreach ($httpHeaders as $key => $value) {
6273
$headers[] = "$key: $value";
@@ -139,6 +150,16 @@ public static function delete($url, $httpHeaders = array())
139150
return self::processRequest($ch);
140151
}
141152

153+
/**
154+
* Set curl additional configuration
155+
*
156+
* @param array $config
157+
*/
158+
public static function config($config = array())
159+
{
160+
self::$config = $config;
161+
}
162+
142163
/**
143164
* Execute a request, release the resource and return output
144165
*

lib/ShopifySDK.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ public static function config($config)
351351
static::$timeAllowedForEachApiCall = $config['AllowedTimePerCall'];
352352
}
353353

354+
if (isset($config['Curl']) && is_array($config['Curl'])) {
355+
CurlRequest::config($config['Curl']);
356+
}
357+
354358
return new ShopifySDK;
355359
}
356360

0 commit comments

Comments
 (0)