File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ require __DIR__ . '/../vendor/autoload.php ' ;
3
+
4
+ use \Curl \MultiCurl ;
5
+
6
+ $ urls = array (
7
+ 'tag3 ' => 'https://httpbin.org/post ' ,
8
+ 'tag4 ' => 'https://httpbin.org/get ' ,
9
+ 'tag5 ' => 'https://httpbin.org/html ' ,
10
+ );
11
+
12
+ $ multi_curl = new MultiCurl ();
13
+
14
+ $ multi_curl ->success (function ($ instance ) {
15
+ echo 'call to ' . $ instance ->id . ' with " ' . $ instance ->myTag . '" was successful. ' . "\n" ;
16
+ });
17
+ $ multi_curl ->error (function ($ instance ) {
18
+ echo 'call to ' . $ instance ->id . ' with " ' . $ instance ->myTag . '" was unsuccessful. ' . "\n" ;
19
+ });
20
+ $ multi_curl ->complete (function ($ instance ) {
21
+ echo 'call to ' . $ instance ->id . ' with " ' . $ instance ->myTag . '" completed. ' . "\n" ;
22
+ });
23
+
24
+ foreach ($ urls as $ tag => $ url ) {
25
+ $ instance = $ multi_curl ->addGet ($ url );
26
+ $ instance ->myTag = $ tag ;
27
+ }
28
+
29
+ $ multi_curl ->start ();
You can’t perform that action at this time.
0 commit comments