-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpClient.php
44 lines (39 loc) · 1.29 KB
/
HttpClient.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 HttpClient extends AbstractClient
{
public function request($api_name, $param_array, $file_array = null)
{
$this->prepare($api_name, $param_array, $file_array);
$requestOpts = array(
'http' => array(
'method' => 'POST',
'timeout' => $this->timeoutReadWrite,
'header' => join("\r\n", $this->requestHeaders),
'content' => $this->requestPostBody,
)
);
if ($this->ignoreSslCheck) {
$requestOpts['ssl'] = array(
'verify_peer' => false,
'verify_peer_name' => false,
);
}
$context = stream_context_create($requestOpts);
$resp = file_get_contents($this->requestUrl, null, $context);
if($resp === false) {
if(!empty($http_response_header)) {
$this->requestError = array(
'error'=>'http error',
'http_response_header'=>$http_response_header,
);
} else {
$this->requestError = array(
'error'=>'file_get_contents error'
);
}
}
return $resp;
}
}