Social Media Share Buttons & Social Sharing Icons - Version 1.9.2

Version Description

  • Instagram followers count issue fixed
  • Twitter count issue fixed
  • Facebook share count issue fixed
Download this release

Release Info

Developer socialdude
Plugin Icon 128x128 Social Media Share Buttons & Social Sharing Icons
Version 1.9.2
Comparing to
See all releases

Code changes from version 1.9.1 to 1.9.2

helpers/twitter-api/twitteroauth.php DELETED
@@ -1,241 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Abraham Williams (abraham@abrah.am) http://abrah.am
5
- *
6
- * The first PHP Library to support OAuth for Twitter's REST API.
7
- */
8
-
9
- /* Load OAuth lib. You can find it at http://oauth.net */
10
- require_once(SFSI_DOCROOT.'/helpers/sfsi_OAuth.php');
11
-
12
- /**
13
- * Twitter OAuth class
14
- */
15
- class TwitterOAuth {
16
- /* Contains the last HTTP status code returned. */
17
- public $http_code;
18
- /* Contains the last API call. */
19
- public $url;
20
- /* Set up the API root URL. */
21
- public $host = "https://api.twitter.com/1.1/";
22
- /* Set timeout default. */
23
- public $timeout = 30;
24
- /* Set connect timeout. */
25
- public $connecttimeout = 30;
26
- /* Verify SSL Cert. */
27
- public $ssl_verifypeer = FALSE;
28
- /* Respons format. */
29
- public $format = 'json';
30
- /* Decode returned json data. */
31
- public $decode_json = TRUE;
32
- /* Contains the last HTTP headers returned. */
33
- public $http_info;
34
- /* Set the useragnet. */
35
- public $useragent = 'TwitterOAuth v0.2.0-beta2';
36
- /* Immediately retry the API call if the response was not successful. */
37
- //public $retry = TRUE;
38
-
39
-
40
-
41
-
42
- /**
43
- * Set API URLS
44
- */
45
- function accessTokenURL() { return 'https://api.twitter.com/oauth/access_token'; }
46
- function authenticateURL() { return 'https://api.twitter.com/oauth/authenticate'; }
47
- function authorizeURL() { return 'https://api.twitter.com/oauth/authorize'; }
48
- function requestTokenURL() { return 'https://api.twitter.com/oauth/request_token'; }
49
-
50
- /**
51
- * Debug helpers
52
- */
53
- function lastStatusCode() { return $this->http_status; }
54
- function lastAPICall() { return $this->last_api_call; }
55
-
56
- /**
57
- * construct TwitterOAuth object
58
- */
59
- function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
60
- $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
61
- $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
62
- if (!empty($oauth_token) && !empty($oauth_token_secret)) {
63
- $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
64
- } else {
65
- $this->token = NULL;
66
- }
67
- }
68
-
69
-
70
- /**
71
- * Get a request_token from Twitter
72
- *
73
- * @returns a key/value array containing oauth_token and oauth_token_secret
74
- */
75
- function getRequestToken($oauth_callback) {
76
- $parameters = array();
77
- $parameters['oauth_callback'] = $oauth_callback;
78
- $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
79
- $token = OAuthUtil::parse_parameters($request);
80
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
81
- return $token;
82
- }
83
-
84
- /**
85
- * Get the authorize URL
86
- *
87
- * @returns a string
88
- */
89
- function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
90
- if (is_array($token)) {
91
- $token = $token['oauth_token'];
92
- }
93
- if (empty($sign_in_with_twitter)) {
94
- return $this->authorizeURL() . "?oauth_token={$token}";
95
- } else {
96
- return $this->authenticateURL() . "?oauth_token={$token}";
97
- }
98
- }
99
-
100
- /**
101
- * Exchange request token and secret for an access token and
102
- * secret, to sign API calls.
103
- *
104
- * @returns array("oauth_token" => "the-access-token",
105
- * "oauth_token_secret" => "the-access-secret",
106
- * "user_id" => "9436992",
107
- * "screen_name" => "abraham")
108
- */
109
- function getAccessToken($oauth_verifier) {
110
- $parameters = array();
111
- $parameters['oauth_verifier'] = $oauth_verifier;
112
- $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
113
- $token = OAuthUtil::parse_parameters($request);
114
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
115
- return $token;
116
- }
117
-
118
- /**
119
- * One time exchange of username and password for access token and secret.
120
- *
121
- * @returns array("oauth_token" => "the-access-token",
122
- * "oauth_token_secret" => "the-access-secret",
123
- * "user_id" => "9436992",
124
- * "screen_name" => "abraham",
125
- * "x_auth_expires" => "0")
126
- */
127
- function getXAuthToken($username, $password) {
128
- $parameters = array();
129
- $parameters['x_auth_username'] = $username;
130
- $parameters['x_auth_password'] = $password;
131
- $parameters['x_auth_mode'] = 'client_auth';
132
- $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
133
- $token = OAuthUtil::parse_parameters($request);
134
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
135
- return $token;
136
- }
137
-
138
- /**
139
- * GET wrapper for oAuthRequest.
140
- */
141
- function get($url, $parameters = array()) {
142
- $response = $this->oAuthRequest($url, 'GET', $parameters);
143
- if ($this->format === 'json' && $this->decode_json) {
144
- return json_decode($response);
145
- }
146
- return $response;
147
- }
148
-
149
- /**
150
- * POST wrapper for oAuthRequest.
151
- */
152
- function post($url, $parameters = array()) {
153
- $response = $this->oAuthRequest($url, 'POST', $parameters);
154
- if ($this->format === 'json' && $this->decode_json) {
155
- return json_decode($response);
156
- }
157
- return $response;
158
- }
159
-
160
- /**
161
- * DELETE wrapper for oAuthReqeust.
162
- */
163
- function delete($url, $parameters = array()) {
164
- $response = $this->oAuthRequest($url, 'DELETE', $parameters);
165
- if ($this->format === 'json' && $this->decode_json) {
166
- return json_decode($response);
167
- }
168
- return $response;
169
- }
170
-
171
- /**
172
- * Format and sign an OAuth / API request
173
- */
174
- function oAuthRequest($url, $method, $parameters) {
175
- if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
176
- $url = "{$this->host}{$url}.{$this->format}";
177
- }
178
- $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
179
- $request->sign_request($this->sha1_method, $this->consumer, $this->token);
180
- switch ($method) {
181
- case 'GET':
182
- return $this->http($request->to_url(), 'GET');
183
- default:
184
- return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
185
- }
186
- }
187
-
188
- /**
189
- * Make an HTTP request
190
- *
191
- * @return API results
192
- */
193
- function http($url, $method, $postfields = NULL) {
194
- $this->http_info = array();
195
- $ci = curl_init();
196
- /* Curl settings */
197
- curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
198
- curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
199
- curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
200
- curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
201
- curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
202
- curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
203
- curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
204
- curl_setopt($ci, CURLOPT_HEADER, FALSE);
205
-
206
- switch ($method) {
207
- case 'POST':
208
- curl_setopt($ci, CURLOPT_POST, TRUE);
209
- if (!empty($postfields)) {
210
- curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
211
- }
212
- break;
213
- case 'DELETE':
214
- curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
215
- if (!empty($postfields)) {
216
- $url = "{$url}?{$postfields}";
217
- }
218
- }
219
-
220
- curl_setopt($ci, CURLOPT_URL, $url);
221
- $response = curl_exec($ci);
222
- $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
223
- $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
224
- $this->url = $url;
225
- curl_close ($ci);
226
- return $response;
227
- }
228
-
229
- /**
230
- * Get the header info to store.
231
- */
232
- function getHeader($ch, $header) {
233
- $i = strpos($header, ':');
234
- if (!empty($i)) {
235
- $key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
236
- $value = trim(substr($header, $i + 2));
237
- $this->http_header[$key] = $value;
238
- }
239
- return strlen($header);
240
- }
241
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
helpers/twitteroauth/autoload.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Use to autoload needed classes without Composer.
5
+ *
6
+ * @param string $class The fully-qualified class name.
7
+ * @return void
8
+ */
9
+ spl_autoload_register(function ($class) {
10
+
11
+ // project-specific namespace prefix
12
+ $prefix = 'Abraham\\TwitterOAuth\\';
13
+
14
+ // base directory for the namespace prefix
15
+ $base_dir = __DIR__ . '/src/';
16
+
17
+ // does the class use the namespace prefix?
18
+ $len = strlen($prefix);
19
+ if (strncmp($prefix, $class, $len) !== 0) {
20
+ // no, move to the next registered autoloader
21
+ return;
22
+ }
23
+
24
+ // get the relative class name
25
+ $relative_class = substr($class, $len);
26
+
27
+ // replace the namespace prefix with the base directory, replace namespace
28
+ // separators with directory separators in the relative class name, append
29
+ // with .php
30
+ $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
31
+
32
+ // if the file exists, require it
33
+ if (file_exists($file)) {
34
+ require $file;
35
+ }
36
+ });
helpers/twitteroauth/src/Config.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Abraham\TwitterOAuth;
4
+
5
+ /**
6
+ * Handle setting and storing config for TwitterOAuth.
7
+ *
8
+ * @author Abraham Williams <abraham@abrah.am>
9
+ */
10
+ class Config
11
+ {
12
+ /** @var int How long to wait for a response from the API */
13
+ protected $timeout = 5;
14
+ /** @var int how long to wait while connecting to the API */
15
+ protected $connectionTimeout = 5;
16
+ /**
17
+ * Decode JSON Response as associative Array
18
+ *
19
+ * @see http://php.net/manual/en/function.json-decode.php
20
+ *
21
+ * @var bool
22
+ */
23
+ protected $decodeJsonAsArray = false;
24
+ /** @var string User-Agent header */
25
+ protected $userAgent = 'TwitterOAuth (+https://twitteroauth.com)';
26
+ /** @var array Store proxy connection details */
27
+ protected $proxy = [];
28
+
29
+ /** @var bool Whether to encode the curl requests with gzip or not */
30
+ protected $gzipEncoding = true;
31
+
32
+ /** @var integer Size for Chunked Uploads */
33
+ protected $chunkSize = 250000; // 0.25 MegaByte
34
+
35
+ /**
36
+ * Set the connection and response timeouts.
37
+ *
38
+ * @param int $connectionTimeout
39
+ * @param int $timeout
40
+ */
41
+ public function setTimeouts($connectionTimeout, $timeout)
42
+ {
43
+ $this->connectionTimeout = (int)$connectionTimeout;
44
+ $this->timeout = (int)$timeout;
45
+ }
46
+
47
+ /**
48
+ * @param bool $value
49
+ */
50
+ public function setDecodeJsonAsArray($value)
51
+ {
52
+ $this->decodeJsonAsArray = (bool)$value;
53
+ }
54
+
55
+ /**
56
+ * @param string $userAgent
57
+ */
58
+ public function setUserAgent($userAgent)
59
+ {
60
+ $this->userAgent = (string)$userAgent;
61
+ }
62
+
63
+ /**
64
+ * @param array $proxy
65
+ */
66
+ public function setProxy(array $proxy)
67
+ {
68
+ $this->proxy = $proxy;
69
+ }
70
+
71
+ /**
72
+ * Whether to encode the curl requests with gzip or not.
73
+ *
74
+ * @param boolean $gzipEncoding
75
+ */
76
+ public function setGzipEncoding($gzipEncoding)
77
+ {
78
+ $this->gzipEncoding = (bool)$gzipEncoding;
79
+ }
80
+
81
+ /**
82
+ * Set the size of each part of file for chunked media upload.
83
+ *
84
+ * @param int $value
85
+ */
86
+ public function setChunkSize($value)
87
+ {
88
+ $this->chunkSize = (int)$value;
89
+ }
90
+ }
helpers/twitteroauth/src/Consumer.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The MIT License
4
+ * Copyright (c) 2007 Andy Smith
5
+ */
6
+ namespace Abraham\TwitterOAuth;
7
+
8
+ class Consumer
9
+ {
10
+ /** @var string */
11
+ public $key;
12
+ /** @var string */
13
+ public $secret;
14
+ /** @var string|null */
15
+ public $callbackUrl;
16
+
17
+ /**
18
+ * @param string $key
19
+ * @param string $secret
20
+ * @param null $callbackUrl
21
+ */
22
+ public function __construct($key, $secret, $callbackUrl = null)
23
+ {
24
+ $this->key = $key;
25
+ $this->secret = $secret;
26
+ $this->callbackUrl = $callbackUrl;
27
+ }
28
+
29
+ /**
30
+ * @return string
31
+ */
32
+ public function __toString()
33
+ {
34
+ return "Consumer[key=$this->key,secret=$this->secret]";
35
+ }
36
+ }
helpers/twitteroauth/src/HmacSha1.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The MIT License
4
+ * Copyright (c) 2007 Andy Smith
5
+ */
6
+ namespace Abraham\TwitterOAuth;
7
+
8
+ /**
9
+ * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
10
+ * where the Signature Base String is the text and the key is the concatenated values (each first
11
+ * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
12
+ * character (ASCII code 38) even if empty.
13
+ * - Chapter 9.2 ("HMAC-SHA1")
14
+ */
15
+ class HmacSha1 extends SignatureMethod
16
+ {
17
+ /**
18
+ * {@inheritDoc}
19
+ */
20
+ public function getName()
21
+ {
22
+ return "HMAC-SHA1";
23
+ }
24
+
25
+ /**
26
+ * {@inheritDoc}
27
+ */
28
+ public function buildSignature(Request $request, Consumer $consumer, Token $token = null)
29
+ {
30
+ $signatureBase = $request->getSignatureBaseString();
31
+
32
+ $parts = [$consumer->secret, null !== $token ? $token->secret : ""];
33
+
34
+ $parts = Util::urlencodeRfc3986($parts);
35
+ $key = implode('&', $parts);
36
+
37
+ return base64_encode(hash_hmac('sha1', $signatureBase, $key, true));
38
+ }
39
+ }
helpers/twitteroauth/src/Request.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The MIT License
4
+ * Copyright (c) 2007 Andy Smith
5
+ */
6
+ namespace Abraham\TwitterOAuth;
7
+
8
+ class Request
9
+ {
10
+ protected $parameters;
11
+ protected $httpMethod;
12
+ protected $httpUrl;
13
+ public static $version = '1.0';
14
+
15
+ /**
16
+ * Constructor
17
+ *
18
+ * @param string $httpMethod
19
+ * @param string $httpUrl
20
+ * @param array|null $parameters
21
+ */
22
+ public function __construct($httpMethod, $httpUrl, array $parameters = [])
23
+ {
24
+ $parameters = array_merge(Util::parseParameters(parse_url($httpUrl, PHP_URL_QUERY)), $parameters);
25
+ $this->parameters = $parameters;
26
+ $this->httpMethod = $httpMethod;
27
+ $this->httpUrl = $httpUrl;
28
+ }
29
+
30
+ /**
31
+ * pretty much a helper function to set up the request
32
+ *
33
+ * @param Consumer $consumer
34
+ * @param Token $token
35
+ * @param string $httpMethod
36
+ * @param string $httpUrl
37
+ * @param array $parameters
38
+ *
39
+ * @return Request
40
+ */
41
+ public static function fromConsumerAndToken(
42
+ Consumer $consumer,
43
+ Token $token = null,
44
+ $httpMethod,
45
+ $httpUrl,
46
+ array $parameters = []
47
+ ) {
48
+ $defaults = [
49
+ "oauth_version" => Request::$version,
50
+ "oauth_nonce" => Request::generateNonce(),
51
+ "oauth_timestamp" => time(),
52
+ "oauth_consumer_key" => $consumer->key
53
+ ];
54
+ if (null !== $token) {
55
+ $defaults['oauth_token'] = $token->key;
56
+ }
57
+
58
+ $parameters = array_merge($defaults, $parameters);
59
+
60
+ return new Request($httpMethod, $httpUrl, $parameters);
61
+ }
62
+
63
+ /**
64
+ * @param string $name
65
+ * @param string $value
66
+ */
67
+ public function setParameter($name, $value)
68
+ {
69
+ $this->parameters[$name] = $value;
70
+ }
71
+
72
+ /**
73
+ * @param $name
74
+ *
75
+ * @return string|null
76
+ */
77
+ public function getParameter($name)
78
+ {
79
+ return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
80
+ }
81
+
82
+ /**
83
+ * @return array
84
+ */
85
+ public function getParameters()
86
+ {
87
+ return $this->parameters;
88
+ }
89
+
90
+ /**
91
+ * @param $name
92
+ */
93
+ public function removeParameter($name)
94
+ {
95
+ unset($this->parameters[$name]);
96
+ }
97
+
98
+ /**
99
+ * The request parameters, sorted and concatenated into a normalized string.
100
+ *
101
+ * @return string
102
+ */
103
+ public function getSignableParameters()
104
+ {
105
+ // Grab all parameters
106
+ $params = $this->parameters;
107
+
108
+ // Remove oauth_signature if present
109
+ // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
110
+ if (isset($params['oauth_signature'])) {
111
+ unset($params['oauth_signature']);
112
+ }
113
+
114
+ return Util::buildHttpQuery($params);
115
+ }
116
+
117
+ /**
118
+ * Returns the base string of this request
119
+ *
120
+ * The base string defined as the method, the url
121
+ * and the parameters (normalized), each urlencoded
122
+ * and the concated with &.
123
+ *
124
+ * @return string
125
+ */
126
+ public function getSignatureBaseString()
127
+ {
128
+ $parts = [
129
+ $this->getNormalizedHttpMethod(),
130
+ $this->getNormalizedHttpUrl(),
131
+ $this->getSignableParameters()
132
+ ];
133
+
134
+ $parts = Util::urlencodeRfc3986($parts);
135
+
136
+ return implode('&', $parts);
137
+ }
138
+
139
+ /**
140
+ * Returns the HTTP Method in uppercase
141
+ *
142
+ * @return string
143
+ */
144
+ public function getNormalizedHttpMethod()
145
+ {
146
+ return strtoupper($this->httpMethod);
147
+ }
148
+
149
+ /**
150
+ * parses the url and rebuilds it to be
151
+ * scheme://host/path
152
+ *
153
+ * @return string
154
+ */
155
+ public function getNormalizedHttpUrl()
156
+ {
157
+ $parts = parse_url($this->httpUrl);
158
+
159
+ $scheme = $parts['scheme'];
160
+ $host = strtolower($parts['host']);
161
+ $path = $parts['path'];
162
+
163
+ return "$scheme://$host$path";
164
+ }
165
+
166
+ /**
167
+ * Builds a url usable for a GET request
168
+ *
169
+ * @return string
170
+ */
171
+ public function toUrl()
172
+ {
173
+ $postData = $this->toPostdata();
174
+ $out = $this->getNormalizedHttpUrl();
175
+ if ($postData) {
176
+ $out .= '?' . $postData;
177
+ }
178
+ return $out;
179
+ }
180
+
181
+ /**
182
+ * Builds the data one would send in a POST request
183
+ *
184
+ * @return string
185
+ */
186
+ public function toPostdata()
187
+ {
188
+ return Util::buildHttpQuery($this->parameters);
189
+ }
190
+
191
+ /**
192
+ * Builds the Authorization: header
193
+ *
194
+ * @return string
195
+ * @throws TwitterOAuthException
196
+ */
197
+ public function toHeader()
198
+ {
199
+ $first = true;
200
+ $out = 'Authorization: OAuth';
201
+ foreach ($this->parameters as $k => $v) {
202
+ if (substr($k, 0, 5) != "oauth") {
203
+ continue;
204
+ }
205
+ if (is_array($v)) {
206
+ throw new TwitterOAuthException('Arrays not supported in headers');
207
+ }
208
+ $out .= ($first) ? ' ' : ', ';
209
+ $out .= Util::urlencodeRfc3986($k) . '="' . Util::urlencodeRfc3986($v) . '"';
210
+ $first = false;
211
+ }
212
+ return $out;
213
+ }
214
+
215
+ /**
216
+ * @return string
217
+ */
218
+ public function __toString()
219
+ {
220
+ return $this->toUrl();
221
+ }
222
+
223
+ /**
224
+ * @param SignatureMethod $signatureMethod
225
+ * @param Consumer $consumer
226
+ * @param Token $token
227
+ */
228
+ public function signRequest(SignatureMethod $signatureMethod, Consumer $consumer, Token $token = null)
229
+ {
230
+ $this->setParameter("oauth_signature_method", $signatureMethod->getName());
231
+ $signature = $this->buildSignature($signatureMethod, $consumer, $token);
232
+ $this->setParameter("oauth_signature", $signature);
233
+ }
234
+
235
+ /**
236
+ * @param SignatureMethod $signatureMethod
237
+ * @param Consumer $consumer
238
+ * @param Token $token
239
+ *
240
+ * @return string
241
+ */
242
+ public function buildSignature(SignatureMethod $signatureMethod, Consumer $consumer, Token $token = null)
243
+ {
244
+ return $signatureMethod->buildSignature($this, $consumer, $token);
245
+ }
246
+
247
+ /**
248
+ * @return string
249
+ */
250
+ public static function generateNonce()
251
+ {
252
+ return md5(microtime() . mt_rand());
253
+ }
254
+ }
helpers/twitteroauth/src/Response.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Abraham\TwitterOAuth;
4
+
5
+ /**
6
+ * The result of the most recent API request.
7
+ *
8
+ * @author Abraham Williams <abraham@abrah.am>
9
+ */
10
+ class Response
11
+ {
12
+ /** @var string|null API path from the most recent request */
13
+ private $apiPath;
14
+ /** @var int HTTP status code from the most recent request */
15
+ private $httpCode = 0;
16
+ /** @var array HTTP headers from the most recent request */
17
+ private $headers = [];
18
+ /** @var array|object Response body from the most recent request */
19
+ private $body = [];
20
+ /** @var array HTTP headers from the most recent request that start with X */
21
+ private $xHeaders = [];
22
+
23
+ /**
24
+ * @param string $apiPath
25
+ */
26
+ public function setApiPath($apiPath)
27
+ {
28
+ $this->apiPath = $apiPath;
29
+ }
30
+
31
+ /**
32
+ * @return string|null
33
+ */
34
+ public function getApiPath()
35
+ {
36
+ return $this->apiPath;
37
+ }
38
+
39
+ /**
40
+ * @param array|object $body
41
+ */
42
+ public function setBody($body)
43
+ {
44
+ $this->body = $body;
45
+ }
46
+
47
+ /**
48
+ * @return array|object|string
49
+ */
50
+ public function getBody()
51
+ {
52
+ return $this->body;
53
+ }
54
+
55
+ /**
56
+ * @param int $httpCode
57
+ */
58
+ public function setHttpCode($httpCode)
59
+ {
60
+ $this->httpCode = $httpCode;
61
+ }
62
+
63
+ /**
64
+ * @return int
65
+ */
66
+ public function getHttpCode()
67
+ {
68
+ return $this->httpCode;
69
+ }
70
+
71
+ /**
72
+ * @param array $headers
73
+ */
74
+ public function setHeaders(array $headers)
75
+ {
76
+ foreach ($headers as $key => $value) {
77
+ if (substr($key, 0, 1) == 'x') {
78
+ $this->xHeaders[$key] = $value;
79
+ }
80
+ }
81
+ $this->headers = $headers;
82
+ }
83
+
84
+ /**
85
+ * @return array
86
+ */
87
+ public function getsHeaders()
88
+ {
89
+ return $this->headers;
90
+ }
91
+
92
+ /**
93
+ * @param array $xHeaders
94
+ */
95
+ public function setXHeaders(array $xHeaders = [])
96
+ {
97
+ $this->xHeaders = $xHeaders;
98
+ }
99
+
100
+ /**
101
+ * @return array
102
+ */
103
+ public function getXHeaders()
104
+ {
105
+ return $this->xHeaders;
106
+ }
107
+ }
helpers/twitteroauth/src/SignatureMethod.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The MIT License
4
+ * Copyright (c) 2007 Andy Smith
5
+ */
6
+ namespace Abraham\TwitterOAuth;
7
+
8
+ /**
9
+ * A class for implementing a Signature Method
10
+ * See section 9 ("Signing Requests") in the spec
11
+ */
12
+ abstract class SignatureMethod
13
+ {
14
+ /**
15
+ * Needs to return the name of the Signature Method (ie HMAC-SHA1)
16
+ *
17
+ * @return string
18
+ */
19
+ abstract public function getName();
20
+
21
+ /**
22
+ * Build up the signature
23
+ * NOTE: The output of this function MUST NOT be urlencoded.
24
+ * the encoding is handled in OAuthRequest when the final
25
+ * request is serialized
26
+ *
27
+ * @param Request $request
28
+ * @param Consumer $consumer
29
+ * @param Token $token
30
+ *
31
+ * @return string
32
+ */
33
+ abstract public function buildSignature(Request $request, Consumer $consumer, Token $token = null);
34
+
35
+ /**
36
+ * Verifies that a given signature is correct
37
+ *
38
+ * @param Request $request
39
+ * @param Consumer $consumer
40
+ * @param Token $token
41
+ * @param string $signature
42
+ *
43
+ * @return bool
44
+ */
45
+ public function checkSignature(Request $request, Consumer $consumer, Token $token, $signature)
46
+ {
47
+ $built = $this->buildSignature($request, $consumer, $token);
48
+
49
+ // Check for zero length, although unlikely here
50
+ if (strlen($built) == 0 || strlen($signature) == 0) {
51
+ return false;
52
+ }
53
+
54
+ if (strlen($built) != strlen($signature)) {
55
+ return false;
56
+ }
57
+
58
+ // Avoid a timing leak with a (hopefully) time insensitive compare
59
+ $result = 0;
60
+ for ($i = 0; $i < strlen($signature); $i++) {
61
+ $result |= ord($built{$i}) ^ ord($signature{$i});
62
+ }
63
+
64
+ return $result == 0;
65
+ }
66
+ }
helpers/twitteroauth/src/Token.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The MIT License
4
+ * Copyright (c) 2007 Andy Smith
5
+ */
6
+ namespace Abraham\TwitterOAuth;
7
+
8
+ class Token
9
+ {
10
+ /** @var string */
11
+ public $key;
12
+ /** @var string */
13
+ public $secret;
14
+
15
+ /**
16
+ * @param string $key The OAuth Token
17
+ * @param string $secret The OAuth Token Secret
18
+ */
19
+ public function __construct($key, $secret)
20
+ {
21
+ $this->key = $key;
22
+ $this->secret = $secret;
23
+ }
24
+
25
+ /**
26
+ * Generates the basic string serialization of a token that a server
27
+ * would respond to request_token and access_token calls with
28
+ *
29
+ * @return string
30
+ */
31
+ public function __toString()
32
+ {
33
+ return sprintf("oauth_token=%s&oauth_token_secret=%s",
34
+ Util::urlencodeRfc3986($this->key),
35
+ Util::urlencodeRfc3986($this->secret)
36
+ );
37
+ }
38
+ }
helpers/twitteroauth/src/TwitterOAuth.php ADDED
@@ -0,0 +1,508 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The most popular PHP library for use with the Twitter OAuth REST API.
4
+ *
5
+ * @license MIT
6
+ */
7
+ namespace Abraham\TwitterOAuth;
8
+
9
+ use Abraham\TwitterOAuth\Util\JsonDecoder;
10
+
11
+ /**
12
+ * TwitterOAuth class for interacting with the Twitter API.
13
+ *
14
+ * @author Abraham Williams <abraham@abrah.am>
15
+ */
16
+ class TwitterOAuth extends Config
17
+ {
18
+ const API_VERSION = '1.1';
19
+ const API_HOST = 'https://api.twitter.com';
20
+ const UPLOAD_HOST = 'https://upload.twitter.com';
21
+
22
+ /** @var Response details about the result of the last request */
23
+ private $response;
24
+ /** @var string|null Application bearer token */
25
+ private $bearer;
26
+ /** @var Consumer Twitter application details */
27
+ private $consumer;
28
+ /** @var Token|null User access token details */
29
+ private $token;
30
+ /** @var HmacSha1 OAuth 1 signature type used by Twitter */
31
+ private $signatureMethod;
32
+
33
+ /**
34
+ * Constructor
35
+ *
36
+ * @param string $consumerKey The Application Consumer Key
37
+ * @param string $consumerSecret The Application Consumer Secret
38
+ * @param string|null $oauthToken The Client Token (optional)
39
+ * @param string|null $oauthTokenSecret The Client Token Secret (optional)
40
+ */
41
+ public function __construct($consumerKey, $consumerSecret, $oauthToken = null, $oauthTokenSecret = null)
42
+ {
43
+ $this->resetLastResponse();
44
+ $this->signatureMethod = new HmacSha1();
45
+ $this->consumer = new Consumer($consumerKey, $consumerSecret);
46
+ if (!empty($oauthToken) && !empty($oauthTokenSecret)) {
47
+ $this->token = new Token($oauthToken, $oauthTokenSecret);
48
+ }
49
+ if (empty($oauthToken) && !empty($oauthTokenSecret)) {
50
+ $this->bearer = $oauthTokenSecret;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * @param string $oauthToken
56
+ * @param string $oauthTokenSecret
57
+ */
58
+ public function setOauthToken($oauthToken, $oauthTokenSecret)
59
+ {
60
+ $this->token = new Token($oauthToken, $oauthTokenSecret);
61
+ }
62
+
63
+ /**
64
+ * @return string|null
65
+ */
66
+ public function getLastApiPath()
67
+ {
68
+ return $this->response->getApiPath();
69
+ }
70
+
71
+ /**
72
+ * @return int
73
+ */
74
+ public function getLastHttpCode()
75
+ {
76
+ return $this->response->getHttpCode();
77
+ }
78
+
79
+ /**
80
+ * @return array
81
+ */
82
+ public function getLastXHeaders()
83
+ {
84
+ return $this->response->getXHeaders();
85
+ }
86
+
87
+ /**
88
+ * @return array|object|null
89
+ */
90
+ public function getLastBody()
91
+ {
92
+ return $this->response->getBody();
93
+ }
94
+
95
+ /**
96
+ * Resets the last response cache.
97
+ */
98
+ public function resetLastResponse()
99
+ {
100
+ $this->response = new Response();
101
+ }
102
+
103
+ /**
104
+ * Make URLs for user browser navigation.
105
+ *
106
+ * @param string $path
107
+ * @param array $parameters
108
+ *
109
+ * @return string
110
+ */
111
+ public function url($path, array $parameters)
112
+ {
113
+ $this->resetLastResponse();
114
+ $this->response->setApiPath($path);
115
+ $query = http_build_query($parameters);
116
+ return sprintf('%s/%s?%s', self::API_HOST, $path, $query);
117
+ }
118
+
119
+ /**
120
+ * Make /oauth/* requests to the API.
121
+ *
122
+ * @param string $path
123
+ * @param array $parameters
124
+ *
125
+ * @return array
126
+ * @throws TwitterOAuthException
127
+ */
128
+ public function oauth($path, array $parameters = [])
129
+ {
130
+ $response = [];
131
+ $this->resetLastResponse();
132
+ $this->response->setApiPath($path);
133
+ $url = sprintf('%s/%s', self::API_HOST, $path);
134
+ $result = $this->oAuthRequest($url, 'POST', $parameters);
135
+
136
+ if ($this->getLastHttpCode() != 200) {
137
+ throw new TwitterOAuthException($result);
138
+ }
139
+
140
+ parse_str($result, $response);
141
+ $this->response->setBody($response);
142
+
143
+ return $response;
144
+ }
145
+
146
+ /**
147
+ * Make /oauth2/* requests to the API.
148
+ *
149
+ * @param string $path
150
+ * @param array $parameters
151
+ *
152
+ * @return array|object
153
+ */
154
+ public function oauth2($path, array $parameters = [])
155
+ {
156
+ $method = 'POST';
157
+ $this->resetLastResponse();
158
+ $this->response->setApiPath($path);
159
+ $url = sprintf('%s/%s', self::API_HOST, $path);
160
+ $request = Request::fromConsumerAndToken($this->consumer, $this->token, $method, $url, $parameters);
161
+ $authorization = 'Authorization: Basic ' . $this->encodeAppAuthorization($this->consumer);
162
+ $result = $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters);
163
+ $response = JsonDecoder::decode($result, $this->decodeJsonAsArray);
164
+ $this->response->setBody($response);
165
+ return $response;
166
+ }
167
+
168
+ /**
169
+ * Make GET requests to the API.
170
+ *
171
+ * @param string $path
172
+ * @param array $parameters
173
+ *
174
+ * @return array|object
175
+ */
176
+ public function get($path, array $parameters = [])
177
+ {
178
+ return $this->http('GET', self::API_HOST, $path, $parameters);
179
+ }
180
+
181
+ /**
182
+ * Make POST requests to the API.
183
+ *
184
+ * @param string $path
185
+ * @param array $parameters
186
+ *
187
+ * @return array|object
188
+ */
189
+ public function post($path, array $parameters = [])
190
+ {
191
+ return $this->http('POST', self::API_HOST, $path, $parameters);
192
+ }
193
+
194
+ /**
195
+ * Make DELETE requests to the API.
196
+ *
197
+ * @param string $path
198
+ * @param array $parameters
199
+ *
200
+ * @return array|object
201
+ */
202
+ public function delete($path, array $parameters = [])
203
+ {
204
+ return $this->http('DELETE', self::API_HOST, $path, $parameters);
205
+ }
206
+
207
+ /**
208
+ * Make PUT requests to the API.
209
+ *
210
+ * @param string $path
211
+ * @param array $parameters
212
+ *
213
+ * @return array|object
214
+ */
215
+ public function put($path, array $parameters = [])
216
+ {
217
+ return $this->http('PUT', self::API_HOST, $path, $parameters);
218
+ }
219
+
220
+ /**
221
+ * Upload media to upload.twitter.com.
222
+ *
223
+ * @param string $path
224
+ * @param array $parameters
225
+ * @param boolean $chunked
226
+ *
227
+ * @return array|object
228
+ */
229
+ public function upload($path, array $parameters = [], $chunked = false)
230
+ {
231
+ if ($chunked) {
232
+ return $this->uploadMediaChunked($path, $parameters);
233
+ } else {
234
+ return $this->uploadMediaNotChunked($path, $parameters);
235
+ }
236
+ }
237
+
238
+ /**
239
+ * Private method to upload media (not chunked) to upload.twitter.com.
240
+ *
241
+ * @param string $path
242
+ * @param array $parameters
243
+ *
244
+ * @return array|object
245
+ */
246
+ private function uploadMediaNotChunked($path, array $parameters)
247
+ {
248
+ $file = file_get_contents($parameters['media']);
249
+ $base = base64_encode($file);
250
+ $parameters['media'] = $base;
251
+ return $this->http('POST', self::UPLOAD_HOST, $path, $parameters);
252
+ }
253
+
254
+ /**
255
+ * Private method to upload media (chunked) to upload.twitter.com.
256
+ *
257
+ * @param string $path
258
+ * @param array $parameters
259
+ *
260
+ * @return array|object
261
+ */
262
+ private function uploadMediaChunked($path, array $parameters)
263
+ {
264
+ $init = $this->http('POST', self::UPLOAD_HOST, $path, $this->mediaInitParameters($parameters));
265
+ // Append
266
+ $segmentIndex = 0;
267
+ $media = fopen($parameters['media'], 'rb');
268
+ while (!feof($media))
269
+ {
270
+ $this->http('POST', self::UPLOAD_HOST, 'media/upload', [
271
+ 'command' => 'APPEND',
272
+ 'media_id' => $init->media_id_string,
273
+ 'segment_index' => $segmentIndex++,
274
+ 'media_data' => base64_encode(fread($media, $this->chunkSize))
275
+ ]);
276
+ }
277
+ fclose($media);
278
+ // Finalize
279
+ $finalize = $this->http('POST', self::UPLOAD_HOST, 'media/upload', [
280
+ 'command' => 'FINALIZE',
281
+ 'media_id' => $init->media_id_string
282
+ ]);
283
+ return $finalize;
284
+ }
285
+
286
+ /**
287
+ * Private method to get params for upload media chunked init.
288
+ * Twitter docs: https://dev.twitter.com/rest/reference/post/media/upload-init.html
289
+ *
290
+ * @param array $parameters
291
+ *
292
+ * @return array
293
+ */
294
+ private function mediaInitParameters(array $parameters)
295
+ {
296
+ $return = [
297
+ 'command' => 'INIT',
298
+ 'media_type' => $parameters['media_type'],
299
+ 'total_bytes' => filesize($parameters['media'])
300
+ ];
301
+ if (isset($parameters['additional_owners'])) {
302
+ $return['additional_owners'] = $parameters['additional_owners'];
303
+ }
304
+ if (isset($parameters['media_category'])) {
305
+ $return['media_category'] = $parameters['media_category'];
306
+ }
307
+ return $return;
308
+ }
309
+
310
+ /**
311
+ * @param string $method
312
+ * @param string $host
313
+ * @param string $path
314
+ * @param array $parameters
315
+ *
316
+ * @return array|object
317
+ */
318
+ private function http($method, $host, $path, array $parameters)
319
+ {
320
+ $this->resetLastResponse();
321
+ $url = sprintf('%s/%s/%s.json', $host, self::API_VERSION, $path);
322
+ $this->response->setApiPath($path);
323
+ $result = $this->oAuthRequest($url, $method, $parameters);
324
+ $response = JsonDecoder::decode($result, $this->decodeJsonAsArray);
325
+ $this->response->setBody($response);
326
+ return $response;
327
+ }
328
+
329
+ /**
330
+ * Format and sign an OAuth / API request
331
+ *
332
+ * @param string $url
333
+ * @param string $method
334
+ * @param array $parameters
335
+ *
336
+ * @return string
337
+ * @throws TwitterOAuthException
338
+ */
339
+ private function oAuthRequest($url, $method, array $parameters)
340
+ {
341
+ $request = Request::fromConsumerAndToken($this->consumer, $this->token, $method, $url, $parameters);
342
+ if (array_key_exists('oauth_callback', $parameters)) {
343
+ // Twitter doesn't like oauth_callback as a parameter.
344
+ unset($parameters['oauth_callback']);
345
+ }
346
+ if ($this->bearer === null) {
347
+ $request->signRequest($this->signatureMethod, $this->consumer, $this->token);
348
+ $authorization = $request->toHeader();
349
+ if (array_key_exists('oauth_verifier', $parameters)) {
350
+ // Twitter doesn't always work with oauth in the body and in the header
351
+ // and it's already included in the $authorization header
352
+ unset($parameters['oauth_verifier']);
353
+ }
354
+ } else {
355
+ $authorization = 'Authorization: Bearer ' . $this->bearer;
356
+ }
357
+ return $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters);
358
+ }
359
+
360
+ /**
361
+ * Set Curl options.
362
+ *
363
+ * @return array
364
+ */
365
+ private function curlOptions()
366
+ {
367
+ $options = [
368
+ // CURLOPT_VERBOSE => true,
369
+ CURLOPT_CONNECTTIMEOUT => $this->connectionTimeout,
370
+ CURLOPT_HEADER => true,
371
+ CURLOPT_RETURNTRANSFER => true,
372
+ CURLOPT_SSL_VERIFYHOST => 2,
373
+ CURLOPT_SSL_VERIFYPEER => true,
374
+ CURLOPT_TIMEOUT => $this->timeout,
375
+ CURLOPT_USERAGENT => $this->userAgent,
376
+ ];
377
+
378
+ if ($this->useCAFile()) {
379
+ $options[CURLOPT_CAINFO] = __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem';
380
+ }
381
+
382
+ if($this->gzipEncoding) {
383
+ $options[CURLOPT_ENCODING] = 'gzip';
384
+ }
385
+
386
+ if (!empty($this->proxy)) {
387
+ $options[CURLOPT_PROXY] = $this->proxy['CURLOPT_PROXY'];
388
+ $options[CURLOPT_PROXYUSERPWD] = $this->proxy['CURLOPT_PROXYUSERPWD'];
389
+ $options[CURLOPT_PROXYPORT] = $this->proxy['CURLOPT_PROXYPORT'];
390
+ $options[CURLOPT_PROXYAUTH] = CURLAUTH_BASIC;
391
+ $options[CURLOPT_PROXYTYPE] = CURLPROXY_HTTP;
392
+ }
393
+
394
+ return $options;
395
+ }
396
+
397
+ /**
398
+ * Make an HTTP request
399
+ *
400
+ * @param string $url
401
+ * @param string $method
402
+ * @param string $authorization
403
+ * @param array $postfields