1
1
<?php
2
- namespace OAuth_io ;
3
2
3
+
4
+
5
+ namespace OAuth_io ;
6
+ use Unirest \Request as Request ;
4
7
class HttpWrapper {
5
8
public function __create () {
6
9
}
7
-
10
+
8
11
private function array_map_recursive ($ callback , $ array ) {
9
12
foreach ($ array as $ key => $ value ) {
10
13
if (is_object ($ array [$ key ])) {
@@ -15,10 +18,10 @@ private function array_map_recursive($callback, $array) {
15
18
}
16
19
return $ array ;
17
20
}
18
-
21
+
19
22
public function make_request ($ options ) {
20
23
$ injector = Injector::getInstance ();
21
-
24
+
22
25
$ url = $ options ['url ' ];
23
26
$ method = $ options ['method ' ];
24
27
$ headers = $ options ['headers ' ];
@@ -30,26 +33,9 @@ public function make_request($options) {
30
33
}
31
34
$ url = str_replace ('%2C ' , ', ' , $ url );
32
35
33
- \Unirest::verifyPeer ($ injector ->ssl_verification );
34
- if ($ options ['method ' ] == 'GET ' ) {
35
- $ response = \Unirest::get ($ url , $ headers );
36
- }
37
-
38
- if ($ options ['method ' ] == 'POST ' ) {
39
- $ response = \Unirest::post ($ url , $ headers , $ body );
40
- }
41
-
42
- if ($ options ['method ' ] == 'PUT ' ) {
43
- $ response = \Unirest::put ($ url , $ headers , $ body );
44
- }
45
-
46
- if ($ options ['method ' ] == 'DELETE ' ) {
47
- $ response = \Unirest::delete ($ url , $ headers );
48
- }
49
-
50
- if ($ options ['method ' ] == 'PATCH ' ) {
51
- $ response = \Unirest::patch ($ url , $ headers , $ body );
52
- }
36
+
37
+ Request::verifyPeer ($ injector ->ssl_verification );
38
+ $ response = Request::send ($ options ['method ' ], $ url , $ body , $ headers );
53
39
54
40
return $ response ;
55
41
}
0 commit comments