You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
980 B

2 years ago
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jaeger <JaegerCode@gmail.com>
  5. * Date: 18/12/10
  6. * Time: 下午6:51
  7. */
  8. require __DIR__.'/../vendor/autoload.php';
  9. use Jaeger\GHttp;
  10. use GuzzleHttp\Psr7\Request;
  11. $requests = [
  12. new Request('POST','http://httpbin.org/post',[
  13. 'Content-Type' => 'application/x-www-form-urlencoded',
  14. 'User-Agent' => 'g-http'
  15. ],http_build_query([
  16. 'name' => 'php'
  17. ])),
  18. new Request('POST','http://httpbin.org/post',[
  19. 'Content-Type' => 'application/x-www-form-urlencoded',
  20. 'User-Agent' => 'g-http'
  21. ],http_build_query([
  22. 'name' => 'go'
  23. ])),
  24. new Request('POST','http://httpbin.org/post',[
  25. 'Content-Type' => 'application/x-www-form-urlencoded',
  26. 'User-Agent' => 'g-http'
  27. ],http_build_query([
  28. 'name' => 'c#'
  29. ]))
  30. ];
  31. GHttp::multiRequest($requests)->success(function($response,$index){
  32. print_r((String)$response->getBody());
  33. print_r($index);
  34. })->post();