1 | <?php |
||
16 | class OAuth |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * OAuth signature method algorithm. |
||
21 | */ |
||
22 | const HASH_ALGORITHM = 'SHA256'; |
||
23 | |||
24 | /** |
||
25 | * API endpoint URL. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $url; |
||
30 | |||
31 | /** |
||
32 | * Consumer key. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $consumerKey; |
||
37 | |||
38 | /** |
||
39 | * Consumer secret. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $consumerSecret; |
||
44 | |||
45 | /** |
||
46 | * API version. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $apiVersion; |
||
51 | |||
52 | /** |
||
53 | * Request method. |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $method; |
||
58 | |||
59 | /** |
||
60 | * Request parameters. |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $parameters; |
||
65 | |||
66 | /** |
||
67 | * Timestamp. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $timestamp; |
||
72 | |||
73 | /** |
||
74 | * Initialize oAuth class. |
||
75 | * |
||
76 | * @param string $url Store URL. |
||
77 | * @param string $consumerKey Consumer key. |
||
78 | * @param string $consumerSecret Consumer Secret. |
||
79 | * @param string $method Request method. |
||
80 | * @param string $apiVersion API version. |
||
81 | * @param array $parameters Request parameters. |
||
82 | * @param string $timestamp Timestamp. |
||
83 | */ |
||
84 | public function __construct( |
||
101 | |||
102 | /** |
||
103 | * Encode according to RFC 3986. |
||
104 | * |
||
105 | * @param string|array $value Value to be normalized. |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | protected function encode($value) |
||
117 | |||
118 | /** |
||
119 | * Normalize parameters. |
||
120 | * |
||
121 | * @param array $parameters Parameters to normalize. |
||
122 | * |
||
123 | * @return array |
||
124 | */ |
||
125 | protected function normalizeParameters($parameters) |
||
139 | |||
140 | /** |
||
141 | * Process filters. |
||
142 | * |
||
143 | * @param array $parameters Request parameters. |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | protected function processFilters($parameters) |
||
159 | |||
160 | /** |
||
161 | * Get secret. |
||
162 | * |
||
163 | * @return string |
||
164 | */ |
||
165 | protected function getSecret() |
||
176 | |||
177 | /** |
||
178 | * Generate oAuth1.0 signature. |
||
179 | * |
||
180 | * @param array $parameters Request parameters including oauth. |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | protected function generateOauthSignature($parameters) |
||
202 | |||
203 | /** |
||
204 | * Creates an array of urlencoded strings out of each array key/value pairs. |
||
205 | * |
||
206 | * @param array $params Array of parameters to convert. |
||
207 | * @param array $queryParams Array to extend. |
||
208 | * @param string $key Optional Array key to append |
||
209 | * @return string Array of urlencoded strings |
||
210 | */ |
||
211 | protected function joinWithEqualsSign($params, $queryParams = [], $key = '') |
||
228 | |||
229 | /** |
||
230 | * Sort parameters. |
||
231 | * |
||
232 | * @param array $parameters Parameters to sort in byte-order. |
||
233 | * |
||
234 | * @return array |
||
235 | */ |
||
236 | protected function getSortedParameters($parameters) |
||
248 | |||
249 | /** |
||
250 | * Get oAuth1.0 parameters. |
||
251 | * |
||
252 | * @return string |
||
253 | */ |
||
254 | public function getParameters() |
||
268 | } |
||
269 |