Skip to content

Commit 30bda65

Browse files
authored
Merge pull request #39 from nguyenanhung/develop
Refactor Project and Update README
2 parents 604b9a5 + 01b9894 commit 30bda65

16 files changed

+792
-988
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Library Interface Requests use cURL, File Get Contents, SOAP Requests
1010

11-
Library use package: Curl, GuzzleHttp, Requests and nuSoap
11+
Library use package: Curl, GuzzleHttp and nuSOAP
1212

1313
### Installation
1414

@@ -60,7 +60,7 @@ require '/your/to/path/vendor/autoload.php';
6060
use \nguyenanhung\MyRequests\MyRequests;
6161
$requests = new MyRequests();
6262

63-
echo $requests->getVersion(); // Print: 0.1.3.4
63+
echo $requests->getVersion(); // Print: 1.0.14
6464
```
6565

6666
##### Send Request
@@ -90,10 +90,7 @@ $request->__construct();
9090
$request->setHeader($headers);
9191
$request->setOptions($options);
9292

93-
echo $requests->getVersion(); // Print: 0.1.3.4
94-
95-
$pyRequest = $request->pyRequest($url, $data, $method);
96-
d($pyRequest);
93+
echo $request->getVersion(); // Print: 0.1.3.4
9794

9895
$guzzlePhpRequest = $request->guzzlePhpRequest($url, $data, $method);
9996
d($guzzlePhpRequest);

src/BackgroundRequest.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,22 @@ public function __destruct()
8181
* @param string $url Url Endpoint
8282
*
8383
* @return bool TRUE nếu thành công, FALSE nếu thất bại
84-
* @author: 713uk13m <[email protected]>
85-
* @time : 10/16/18 17:15
8684
*
85+
* @author : 713uk13m <[email protected]>
86+
* @copyright: 713uk13m <[email protected]>
87+
* @time : 10/16/18 17:15
8788
*/
8889
public static function backgroundHttpGet($url)
8990
{
9091
$parts = parse_url($url);
91-
if ($parts['scheme'] == 'https') {
92-
$fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : 443, $errno, $errstr, 30);
92+
if (strtolower($parts['scheme']) == 'https') {
93+
$fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : 443, $errno, $errStr, 30);
9394
} else {
94-
$fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 30);
95+
$fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errStr, 30);
9596
}
9697
if (!$fp) {
9798
if (function_exists('log_message')) {
98-
log_message('error', "ERROR: " . json_encode($errno) . " - " . json_encode($errstr));
99+
log_message('error', "ERROR: " . json_encode($errno) . " - " . json_encode($errStr));
99100
}
100101

101102
return FALSE;
@@ -118,21 +119,22 @@ public static function backgroundHttpGet($url)
118119
* @param string $paramString Params to Request
119120
*
120121
* @return bool TRUE nếu thành công, FALSE nếu thất bại
121-
* @author: 713uk13m <[email protected]>
122-
* @time : 10/16/18 17:16
123122
*
123+
* @author : 713uk13m <[email protected]>
124+
* @copyright: 713uk13m <[email protected]>
125+
* @time : 10/16/18 17:16
124126
*/
125127
public static function backgroundHttpPost($url, $paramString = '')
126128
{
127129
$parts = parse_url($url);
128130
if ($parts['scheme'] == 'https') {
129-
$fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : 443, $errno, $errstr, 30);
131+
$fp = fsockopen('ssl://' . $parts['host'], isset($parts['port']) ? $parts['port'] : 443, $errno, $errStr, 30);
130132
} else {
131-
$fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 30);
133+
$fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errStr, 30);
132134
}
133135
if (!$fp) {
134136
if (function_exists('log_message')) {
135-
log_message('error', "ERROR: " . json_encode($errno) . " - " . json_encode($errstr));
137+
log_message('error', "ERROR: " . json_encode($errno) . " - " . json_encode($errStr));
136138
}
137139

138140
return FALSE;

src/BackgroundRequestInterface.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,27 @@ interface BackgroundRequestInterface
2121
/**
2222
* Hàm gọi 1 async GET Request để không delay Main Process
2323
*
24-
* @author: 713uk13m <[email protected]>
25-
* @time : 10/16/18 17:15
26-
*
2724
* @param string $url Url Endpoint
2825
*
2926
* @return bool TRUE nếu thành công, FALSE nếu thất bại
27+
*
28+
* @author : 713uk13m <[email protected]>
29+
* @copyright: 713uk13m <[email protected]>
30+
* @time : 10/16/18 17:15
3031
*/
3132
public static function backgroundHttpGet($url);
3233

3334
/**
3435
* Hàm gọi 1 async POST Request để không delay Main Process
3536
*
36-
* @author: 713uk13m <[email protected]>
37-
* @time : 10/16/18 17:16
38-
*
3937
* @param string $url Url Endpoint
4038
* @param string $paramString Params to Request
4139
*
4240
* @return bool TRUE nếu thành công, FALSE nếu thất bại
41+
*
42+
* @author : 713uk13m <[email protected]>
43+
* @copyright: 713uk13m <[email protected]>
44+
* @time : 10/16/18 17:16
4345
*/
4446
public static function backgroundHttpPost($url, $paramString = '');
4547
}

0 commit comments

Comments
 (0)