forked from fundaev/fake2co
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp.php
49 lines (39 loc) · 1.18 KB
/
http.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
45
46
47
48
49
<?php
$ch_header = null;
function collectHTTPHeader($ch, $header)
{
global $ch_header;
if (is_null($ch) && is_null($header)) {
$ch_header = '';
} else {
$ch_header .= $header;
}
return strlen($header);
}
function getHeaders()
{
global $ch_header;
return $ch_header;
}
function postHttpsRequest($url, $data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'collectHTTPHeader');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
collectHTTPHeader(null, null);
$res = curl_exec($ch);
// Log
$log = date('[H:i:s Y.m.d]');
$log .= ' ' . $url . "\n";
$log .= "POST DATA: " . var_export($data, true) . "\n-----------------------------\n";
$log .= "HEADERS:\n" . var_export(getHeaders(), true) . "\n-----------------------------\n";
$log .= "RESPONSE:\n" . var_export($res, true) . "\n-----------------------------\n\n";
file_put_contents('https.log', $log);
return array(getHeaders(), $res);
}