-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from nguyenanhung/v3.x
Update v3.x
- Loading branch information
Showing
15 changed files
with
3,894 additions
and
3,894 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
{ | ||
"name": "nguyenanhung/requests", | ||
"type": "library", | ||
"description": "My Requests Library", | ||
"keywords": [ | ||
"request", | ||
"http", | ||
"curl", | ||
"get_content", | ||
"rest", | ||
"soap" | ||
], | ||
"homepage": "https://github.com/nguyenanhung/requests", | ||
"license": "GPL-3.0", | ||
"authors": [ | ||
{ | ||
"name": "Nguyen An Hung", | ||
"email": "[email protected]", | ||
"homepage": "https://nguyenanhung.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0", | ||
"ext-curl": "*", | ||
"ext-json": "*", | ||
"ext-iconv": "*", | ||
"symfony/http-foundation": "^6.0 || ^5.3 || ^4.4 || ^3.4", | ||
"symfony/polyfill-mbstring": ">= 1.0", | ||
"php-curl-class/php-curl-class": "^9 || ^8", | ||
"guzzlehttp/guzzle": "^7 || ^6", | ||
"nguyenanhung/nusoap": "^0.9", | ||
"nguyenanhung/my-debug": "^3.0 || ^2.0", | ||
"nguyenanhung/ip-helper": "^2.0 || ^1.0" | ||
}, | ||
"require-dev": { | ||
"kint-php/kint": "^5 || ^4 || ^3 || ^2 || ^1" | ||
}, | ||
"suggest": { | ||
"ext-curl": "Needed to support cURL", | ||
"ext-json": "Needed to support JSON", | ||
"ext-iconv": "Needed to support iconv", | ||
"ext-openssl": "Needed to support SSL", | ||
"ext-mbstring": "Needed to support mb_string" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"nguyenanhung\\MyRequests\\": "src/" | ||
}, | ||
"files": [ | ||
"helpers/helpers.php" | ||
] | ||
} | ||
"name": "nguyenanhung/requests", | ||
"type": "library", | ||
"description": "My Requests Library", | ||
"keywords": [ | ||
"request", | ||
"http", | ||
"curl", | ||
"get_content", | ||
"rest", | ||
"soap" | ||
], | ||
"homepage": "https://github.com/nguyenanhung/requests", | ||
"license": "GPL-3.0", | ||
"authors": [ | ||
{ | ||
"name": "Nguyen An Hung", | ||
"email": "[email protected]", | ||
"homepage": "https://nguyenanhung.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0", | ||
"ext-curl": "*", | ||
"ext-json": "*", | ||
"ext-iconv": "*", | ||
"symfony/http-foundation": "^6.0 || ^5.3 || ^4.4 || ^3.4", | ||
"symfony/polyfill-mbstring": ">= 1.0", | ||
"php-curl-class/php-curl-class": "^9 || ^8", | ||
"guzzlehttp/guzzle": "^7 || ^6", | ||
"nguyenanhung/nusoap": "^0.9", | ||
"nguyenanhung/my-debug": "^4.0 || ^3.0 || ^2.0", | ||
"nguyenanhung/ip-helper": "^2.0 || ^1.0" | ||
}, | ||
"require-dev": { | ||
"kint-php/kint": "^5 || ^4 || ^3 || ^2 || ^1" | ||
}, | ||
"suggest": { | ||
"ext-curl": "Needed to support cURL", | ||
"ext-json": "Needed to support JSON", | ||
"ext-iconv": "Needed to support iconv", | ||
"ext-openssl": "Needed to support SSL", | ||
"ext-mbstring": "Needed to support mb_string" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"nguyenanhung\\MyRequests\\": "src/" | ||
}, | ||
"files": [ | ||
"helpers/helpers.php" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,62 +8,62 @@ | |
* Time: 23:16 | ||
*/ | ||
if (!function_exists('sendSimpleRequest')) { | ||
/** | ||
* Function sendSimpleRequest | ||
* | ||
* @param string $url URL Target Endpoint | ||
* @param string|array|object $data Array Data to Request | ||
* @param string $method GET or POST | ||
* | ||
* @return bool|string|null | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 08/03/2021 20:38 | ||
*/ | ||
function sendSimpleRequest(string $url = '', $data = [], string $method = 'GET') | ||
{ | ||
$target = (!empty($data) && (is_array($data) || is_object($data))) ? $url . '?' . http_build_query($data) : $url; | ||
$method = mb_strtoupper($method); | ||
$curl = curl_init(); | ||
curl_setopt_array($curl, array( | ||
CURLOPT_URL => $target, | ||
CURLOPT_RETURNTRANSFER => true, | ||
CURLOPT_ENCODING => "", | ||
CURLOPT_MAXREDIRS => 10, | ||
CURLOPT_TIMEOUT => 30, | ||
CURLOPT_CUSTOMREQUEST => $method, | ||
CURLOPT_POSTFIELDS => "", | ||
CURLOPT_HTTPHEADER => array(), | ||
)); | ||
$response = curl_exec($curl); | ||
$err = curl_error($curl); | ||
curl_close($curl); | ||
if ($err) { | ||
$message = "cURL Error #: " . $err; | ||
if (function_exists('log_message')) { | ||
log_message('error', $message); | ||
} | ||
/** | ||
* Function sendSimpleRequest | ||
* | ||
* @param string $url URL Target Endpoint | ||
* @param string|array|object $data Array Data to Request | ||
* @param string $method GET or POST | ||
* | ||
* @return bool|string|null | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 08/03/2021 20:38 | ||
*/ | ||
function sendSimpleRequest(string $url = '', $data = [], string $method = 'GET') | ||
{ | ||
$target = (!empty($data) && (is_array($data) || is_object($data))) ? $url . '?' . http_build_query($data) : $url; | ||
$method = mb_strtoupper($method); | ||
$curl = curl_init(); | ||
curl_setopt_array($curl, array( | ||
CURLOPT_URL => $target, | ||
CURLOPT_RETURNTRANSFER => true, | ||
CURLOPT_ENCODING => "", | ||
CURLOPT_MAXREDIRS => 10, | ||
CURLOPT_TIMEOUT => 30, | ||
CURLOPT_CUSTOMREQUEST => $method, | ||
CURLOPT_POSTFIELDS => "", | ||
CURLOPT_HTTPHEADER => array(), | ||
)); | ||
$response = curl_exec($curl); | ||
$err = curl_error($curl); | ||
curl_close($curl); | ||
if ($err) { | ||
$message = "cURL Error #: " . $err; | ||
if (function_exists('log_message')) { | ||
log_message('error', $message); | ||
} | ||
|
||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
return $response; | ||
} | ||
return $response; | ||
} | ||
} | ||
if (!function_exists('getIpAddress')) { | ||
/** | ||
* Function getIpAddress | ||
* | ||
* @param bool $convertToInteger | ||
* | ||
* @return bool|int|string | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/20/2021 10:36 | ||
*/ | ||
function getIpAddress(bool $convertToInteger = false) | ||
{ | ||
$ip = new nguyenanhung\MyRequests\Ip(); | ||
return $ip->getIpAddress($convertToInteger); | ||
} | ||
/** | ||
* Function getIpAddress | ||
* | ||
* @param bool $convertToInteger | ||
* | ||
* @return bool|int|string | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/20/2021 10:36 | ||
*/ | ||
function getIpAddress(bool $convertToInteger = false) | ||
{ | ||
$ip = new nguyenanhung\MyRequests\Ip(); | ||
return $ip->getIpAddress($convertToInteger); | ||
} | ||
} |
Oops, something went wrong.