1 | <?php |
||
12 | class CurlHttpClient implements HttpClient |
||
13 | { |
||
14 | public $cookieName = 'pinterest_cookie'; |
||
15 | |||
16 | /** |
||
17 | * Custom CURL options for requests. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $options = []; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0'; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $headers = []; |
||
32 | |||
33 | /** |
||
34 | * Contains the curl instance. |
||
35 | * |
||
36 | * @var resource |
||
37 | */ |
||
38 | protected $curl; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $cookieJar; |
||
44 | |||
45 | public function __construct() |
||
49 | |||
50 | /** |
||
51 | * Executes curl request. |
||
52 | * |
||
53 | * @param string $url |
||
54 | * @param string $postString |
||
55 | * @param array $headers |
||
56 | * @return string |
||
57 | */ |
||
58 | public function execute($url, $postString = '', array $headers = []) |
||
69 | |||
70 | /** |
||
71 | * Get curl errors. |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | public function getErrors() |
||
79 | |||
80 | /** |
||
81 | * @return null|string |
||
82 | */ |
||
83 | public function getToken() |
||
87 | |||
88 | /** |
||
89 | * @param string $userAgent |
||
90 | * @return $this |
||
91 | */ |
||
92 | public function setUserAgent($userAgent) |
||
100 | |||
101 | /** |
||
102 | * Close the curl resource. |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | protected function close() |
||
110 | |||
111 | /** |
||
112 | * Initializes curl resource with options. |
||
113 | * |
||
114 | * @param string $url |
||
115 | * @param $postString |
||
116 | * @return $this |
||
117 | */ |
||
118 | protected function init($url, $postString) |
||
129 | |||
130 | /** |
||
131 | * @return array |
||
132 | */ |
||
133 | protected function getDefaultHttpOptions() |
||
147 | |||
148 | /** |
||
149 | * Adds necessary curl options for query. |
||
150 | * |
||
151 | * @param string $postString POST query string |
||
152 | * |
||
153 | * @return array |
||
154 | */ |
||
155 | protected function makeHttpOptions($postString = '') |
||
173 | |||
174 | /** |
||
175 | * Set custom Curl options to override default |
||
176 | * |
||
177 | * @param array $options |
||
178 | * @return CurlHttpClient |
||
179 | */ |
||
180 | public function setOptions(array $options) |
||
186 | } |
||
187 |