-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurlClient.php
44 lines (34 loc) · 1.23 KB
/
CurlClient.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Zackyjack\AdvanceAI;
use Zackyjack\AdvanceAI\AbstractClient;
class CurlClient extends AbstractClient
{
public function request($api_name, $param_array, $file_array = null)
{
$this->prepare($api_name, $param_array, $file_array);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_URL, $this->requestUrl);
if ($this->requestHeaders) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->requestHeaders);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestPostBody);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeoutConnect);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeoutReadWrite);
if ($this->ignoreSslCheck) {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
}
$resp = curl_exec($ch);
if($resp === false) {
$this->requestError = array(
'errno'=>curl_errno($ch),
'error'=>curl_error($ch),
);
}
curl_close($ch);
return $resp;
}
}