Skip to content

Commit 5d7901f

Browse files
authored
Merge pull request #66 from nguyenanhung/v3.x
Update v3.x
2 parents 3c30509 + c59ffeb commit 5d7901f

File tree

15 files changed

+3894
-3894
lines changed

15 files changed

+3894
-3894
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Library use package: Curl, GuzzleHttp and nuSOAP
1010

1111
- [x] V1.x, V2.x support all PHP version `>=5.6`
1212
- [x] V3.x support all PHP version `>=7.0`
13+
- [x] V4.x support all PHP version `>=8.0`
1314

1415
## Installation
1516

@@ -26,7 +27,7 @@ unzip master.zip
2627
Step 2: Init to Project
2728

2829
```php
29-
<?php
30+
<?php
3031
require '/your/to/path/MyRequests.php';
3132
use \nguyenanhung\MyRequests\MyRequests;
3233

@@ -45,7 +46,7 @@ composer require nguyenanhung/requests
4546
Step 2: Init to Project
4647

4748
```php
48-
<?php
49+
<?php
4950
require '/your/to/path/vendor/autoload.php';
5051
use \nguyenanhung\MyRequests\MyRequests;
5152
$requests = new MyRequests();

composer.json

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
{
2-
"name": "nguyenanhung/requests",
3-
"type": "library",
4-
"description": "My Requests Library",
5-
"keywords": [
6-
"request",
7-
"http",
8-
"curl",
9-
"get_content",
10-
"rest",
11-
"soap"
12-
],
13-
"homepage": "https://github.com/nguyenanhung/requests",
14-
"license": "GPL-3.0",
15-
"authors": [
16-
{
17-
"name": "Nguyen An Hung",
18-
"email": "[email protected]",
19-
"homepage": "https://nguyenanhung.com",
20-
"role": "Developer"
21-
}
22-
],
23-
"require": {
24-
"php": ">=7.0",
25-
"ext-curl": "*",
26-
"ext-json": "*",
27-
"ext-iconv": "*",
28-
"symfony/http-foundation": "^6.0 || ^5.3 || ^4.4 || ^3.4",
29-
"symfony/polyfill-mbstring": ">= 1.0",
30-
"php-curl-class/php-curl-class": "^9 || ^8",
31-
"guzzlehttp/guzzle": "^7 || ^6",
32-
"nguyenanhung/nusoap": "^0.9",
33-
"nguyenanhung/my-debug": "^3.0 || ^2.0",
34-
"nguyenanhung/ip-helper": "^2.0 || ^1.0"
35-
},
36-
"require-dev": {
37-
"kint-php/kint": "^5 || ^4 || ^3 || ^2 || ^1"
38-
},
39-
"suggest": {
40-
"ext-curl": "Needed to support cURL",
41-
"ext-json": "Needed to support JSON",
42-
"ext-iconv": "Needed to support iconv",
43-
"ext-openssl": "Needed to support SSL",
44-
"ext-mbstring": "Needed to support mb_string"
45-
},
46-
"autoload": {
47-
"psr-4": {
48-
"nguyenanhung\\MyRequests\\": "src/"
49-
},
50-
"files": [
51-
"helpers/helpers.php"
52-
]
53-
}
2+
"name": "nguyenanhung/requests",
3+
"type": "library",
4+
"description": "My Requests Library",
5+
"keywords": [
6+
"request",
7+
"http",
8+
"curl",
9+
"get_content",
10+
"rest",
11+
"soap"
12+
],
13+
"homepage": "https://github.com/nguyenanhung/requests",
14+
"license": "GPL-3.0",
15+
"authors": [
16+
{
17+
"name": "Nguyen An Hung",
18+
"email": "[email protected]",
19+
"homepage": "https://nguyenanhung.com",
20+
"role": "Developer"
21+
}
22+
],
23+
"require": {
24+
"php": ">=7.0",
25+
"ext-curl": "*",
26+
"ext-json": "*",
27+
"ext-iconv": "*",
28+
"symfony/http-foundation": "^6.0 || ^5.3 || ^4.4 || ^3.4",
29+
"symfony/polyfill-mbstring": ">= 1.0",
30+
"php-curl-class/php-curl-class": "^9 || ^8",
31+
"guzzlehttp/guzzle": "^7 || ^6",
32+
"nguyenanhung/nusoap": "^0.9",
33+
"nguyenanhung/my-debug": "^4.0 || ^3.0 || ^2.0",
34+
"nguyenanhung/ip-helper": "^2.0 || ^1.0"
35+
},
36+
"require-dev": {
37+
"kint-php/kint": "^5 || ^4 || ^3 || ^2 || ^1"
38+
},
39+
"suggest": {
40+
"ext-curl": "Needed to support cURL",
41+
"ext-json": "Needed to support JSON",
42+
"ext-iconv": "Needed to support iconv",
43+
"ext-openssl": "Needed to support SSL",
44+
"ext-mbstring": "Needed to support mb_string"
45+
},
46+
"autoload": {
47+
"psr-4": {
48+
"nguyenanhung\\MyRequests\\": "src/"
49+
},
50+
"files": [
51+
"helpers/helpers.php"
52+
]
53+
}
5454
}

helpers/helpers.php

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,62 @@
88
* Time: 23:16
99
*/
1010
if (!function_exists('sendSimpleRequest')) {
11-
/**
12-
* Function sendSimpleRequest
13-
*
14-
* @param string $url URL Target Endpoint
15-
* @param string|array|object $data Array Data to Request
16-
* @param string $method GET or POST
17-
*
18-
* @return bool|string|null
19-
* @author : 713uk13m <[email protected]>
20-
* @copyright: 713uk13m <[email protected]>
21-
* @time : 08/03/2021 20:38
22-
*/
23-
function sendSimpleRequest(string $url = '', $data = [], string $method = 'GET')
24-
{
25-
$target = (!empty($data) && (is_array($data) || is_object($data))) ? $url . '?' . http_build_query($data) : $url;
26-
$method = mb_strtoupper($method);
27-
$curl = curl_init();
28-
curl_setopt_array($curl, array(
29-
CURLOPT_URL => $target,
30-
CURLOPT_RETURNTRANSFER => true,
31-
CURLOPT_ENCODING => "",
32-
CURLOPT_MAXREDIRS => 10,
33-
CURLOPT_TIMEOUT => 30,
34-
CURLOPT_CUSTOMREQUEST => $method,
35-
CURLOPT_POSTFIELDS => "",
36-
CURLOPT_HTTPHEADER => array(),
37-
));
38-
$response = curl_exec($curl);
39-
$err = curl_error($curl);
40-
curl_close($curl);
41-
if ($err) {
42-
$message = "cURL Error #: " . $err;
43-
if (function_exists('log_message')) {
44-
log_message('error', $message);
45-
}
11+
/**
12+
* Function sendSimpleRequest
13+
*
14+
* @param string $url URL Target Endpoint
15+
* @param string|array|object $data Array Data to Request
16+
* @param string $method GET or POST
17+
*
18+
* @return bool|string|null
19+
* @author : 713uk13m <[email protected]>
20+
* @copyright: 713uk13m <[email protected]>
21+
* @time : 08/03/2021 20:38
22+
*/
23+
function sendSimpleRequest(string $url = '', $data = [], string $method = 'GET')
24+
{
25+
$target = (!empty($data) && (is_array($data) || is_object($data))) ? $url . '?' . http_build_query($data) : $url;
26+
$method = mb_strtoupper($method);
27+
$curl = curl_init();
28+
curl_setopt_array($curl, array(
29+
CURLOPT_URL => $target,
30+
CURLOPT_RETURNTRANSFER => true,
31+
CURLOPT_ENCODING => "",
32+
CURLOPT_MAXREDIRS => 10,
33+
CURLOPT_TIMEOUT => 30,
34+
CURLOPT_CUSTOMREQUEST => $method,
35+
CURLOPT_POSTFIELDS => "",
36+
CURLOPT_HTTPHEADER => array(),
37+
));
38+
$response = curl_exec($curl);
39+
$err = curl_error($curl);
40+
curl_close($curl);
41+
if ($err) {
42+
$message = "cURL Error #: " . $err;
43+
if (function_exists('log_message')) {
44+
log_message('error', $message);
45+
}
4646

47-
return null;
48-
}
47+
return null;
48+
}
4949

50-
return $response;
51-
}
50+
return $response;
51+
}
5252
}
5353
if (!function_exists('getIpAddress')) {
54-
/**
55-
* Function getIpAddress
56-
*
57-
* @param bool $convertToInteger
58-
*
59-
* @return bool|int|string
60-
* @author : 713uk13m <[email protected]>
61-
* @copyright: 713uk13m <[email protected]>
62-
* @time : 09/20/2021 10:36
63-
*/
64-
function getIpAddress(bool $convertToInteger = false)
65-
{
66-
$ip = new nguyenanhung\MyRequests\Ip();
67-
return $ip->getIpAddress($convertToInteger);
68-
}
54+
/**
55+
* Function getIpAddress
56+
*
57+
* @param bool $convertToInteger
58+
*
59+
* @return bool|int|string
60+
* @author : 713uk13m <[email protected]>
61+
* @copyright: 713uk13m <[email protected]>
62+
* @time : 09/20/2021 10:36
63+
*/
64+
function getIpAddress(bool $convertToInteger = false)
65+
{
66+
$ip = new nguyenanhung\MyRequests\Ip();
67+
return $ip->getIpAddress($convertToInteger);
68+
}
6969
}

0 commit comments

Comments
 (0)