@@ -40,7 +40,7 @@ echo ("\n" . $raw . "\n");
40
40
More example below...
41
41
42
42
43
- ### Example of synchronous request
43
+ ### More Examples...
44
44
```
45
45
46
46
// ex .1
@@ -76,60 +76,4 @@ $postForm->send(array(
76
76
$raw = $postForm->rawResponse();
77
77
echo ("\n" . $raw . "\n");
78
78
79
- ```
80
-
81
- ### Example of asynchronous request (based on Guzzle promises)
82
-
83
- ```
84
- // GET Async http client example
85
- $atticaPromise = new AtticaPromise();
86
- $wrongUrl = $atticaPromise->asyncGET("blasdaosd");
87
-
88
- var_dump("before wrongUrl...");
89
- $wrongUrl->then(function($v) {
90
- var_dump($v);
91
- });
92
- var_dump("after wrongUrl...");
93
-
94
-
95
- try {
96
- $wrongUrl->wait();
97
- var_dump("promise resolved");
98
- }catch(Exception $ex){
99
- var_dump($ex->getMessage());
100
- }
101
-
102
- // POST Async http client example (application/json)
103
- // chaining promises
104
- $m = $atticaPromise->asyncSendPOST("https://reqres.in/api/users",array(
105
- 'name'=>'hello',
106
- 'job'=>'world'
107
- ),"application/json");
108
-
109
- $m->then(function($v) use ($atticaPromise){
110
- echo $v . "\n";
111
- return $atticaPromise->asyncSendPOST("http://httpbin.org/post",array(
112
- 'a'=>'aaa','b'=>'bbb'
113
- ),'application/x-www-form-urlencoded')->wait();
114
- })->then(function($v) {
115
- echo $v . "\n";
116
- });
117
-
118
- $m->wait();
119
-
120
- // POST Async with asyncRequest example
121
- $data = http_build_query(array(
122
- 'name'=>'asd',
123
- 'job'=>'dsa'
124
- ));
125
- $headers = array(
126
- 'Content-type: application/x-www-form-urlencoded'
127
- );
128
- $custom = $atticaPromise->asyncRequest("http://httpbin.org/post",$headers , CURLOPT_POST , $data);
129
- $custom->then(function($v){
130
- echo $v;
131
- });
132
-
133
- $custom->wait();
134
-
135
79
```
0 commit comments