Skip to content

Commit 478fd2e

Browse files
committed
header send
1 parent ddc0912 commit 478fd2e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

HttpRequest.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
*/
1212
class HttpRequest
1313
{
14-
private $_url = "http://devraph.net/api.php";
14+
private $_url = "";
1515
private $_post = array();
16-
private $_timeout = "10";
16+
private $_timeout = 10;
17+
private $_headers = array();
1718

1819
/**
1920
* Check if curl is enabled or disabled
@@ -26,6 +27,18 @@ private function _enableCurl()
2627
}
2728
}
2829

30+
public function setHeaders($headers = array())
31+
{
32+
$reformated = [];
33+
34+
foreach ($headers as $key => $value) {
35+
$reformated[] = $key . ': ' . $value;
36+
}
37+
38+
$this->_headers = $reformated;
39+
40+
return true;
41+
}
2942
/**
3043
* Execute your request
3144
*
@@ -37,6 +50,7 @@ public function post()
3750
$ch = curl_init();
3851
curl_setopt($ch, CURLOPT_URL, $this->_url);
3952
curl_setopt($ch, CURLOPT_POST, 1);
53+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
4054
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_post);
4155
curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);
4256
$output = curl_exec($ch);
@@ -55,8 +69,6 @@ public function get()
5569
$ch = curl_init();
5670
curl_setopt($ch, CURLOPT_URL, $this->_url);
5771
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
58-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
59-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
6072
curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);
6173
$output = curl_exec($ch);
6274
curl_close($ch);
@@ -92,4 +104,4 @@ public function setTimeout($timeout)
92104
{
93105
$this->_timeout = $timeout;
94106
}
95-
}
107+
}

0 commit comments

Comments
 (0)