| 12345678910111213141516171819202122232425262728 |
- <?php
- class HTTPRequester {
- /**
- * @description Make HTTP-POST call
- * @param $url
- * @param array $params
- * @param $aheader \http\Header
- * @return HTTP-Response body or an empty string if the request fails or is empty
- */
- public static function HTTPPost($url, array $params, array $aheader) {
- $query = http_build_query($params);
- $ch = curl_init();
- if (stripos($url, "https://") !== FALSE) {
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
- }
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $aheader);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
- $response = curl_exec($ch);
- curl_close($ch);
- return $response;
- }
- }
|