File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-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 \Curl ;
5
+ use \Curl \MultiCurl ;
6
+
7
+ $ multi_curl = new MultiCurl ();
8
+ $ multi_curl ->complete (function ($ instance ) {
9
+ echo 'call to " ' . $ instance ->url . '" completed. ' . "\n" ;
10
+ });
11
+
12
+ $ curl_1 = new Curl ();
13
+ $ curl_1 ->setOpt (CURLOPT_POST , true );
14
+ $ curl_1 ->setOpt (CURLOPT_POSTFIELDS , array (
15
+ 'to ' => 'alice ' ,
16
+ 'subject ' => 'hi ' ,
17
+ 'body ' => 'hi Alice ' ,
18
+ ));
19
+ $ curl_1 ->setUrl ('https://httpbin.org/post ' );
20
+ $ multi_curl ->addCurl ($ curl_1 );
21
+
22
+ $ curl_2 = new Curl ();
23
+ $ curl_2 ->setOpt (CURLOPT_POST , true );
24
+ $ curl_2 ->setOpt (CURLOPT_POSTFIELDS , array (
25
+ 'to ' => 'bob ' ,
26
+ 'subject ' => 'hi ' ,
27
+ 'body ' => 'hi Bob ' ,
28
+ ));
29
+ $ curl_2 ->setUrl ('https://httpbin.org/post ' );
30
+ $ multi_curl ->addCurl ($ curl_2 );
31
+
32
+ $ multi_curl ->start ();
You can’t perform that action at this time.
0 commit comments