PHP code example of sinacms / multihttp

1. Go to this page and download the library: Download sinacms/multihttp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sinacms / multihttp example snippets



// Include Composer's autoload file if not already included.
::create()->get('http://sina.com.cn', array(
          'timeout' => 3,
	  'expects_mime'=>'json',
	  'retry_times' => 3,
	  'ip' => '127.0.0.1:8080',//alias for proxy, better than raw proxy
          'callback' => function (Response $response) {
              echo $response->body;
          },
          ))->send();
      
//method 2
$result = Request::create()->post(
      'http://127.0.0.1',array('data'=>'this_is_post_data'), array(
          'callback' => function (Response $response) {
              echo $response->body;
          }))->send();



ultiHttp\MultiRequest;
use MultiHttp\Response;


$mr  = MultiRequest::create();
$rtn = $mr->add('GET', 'http://sina.cn',array(), array(
                  'timeout' => 3,
                  'callback' => function (Response $response) {
                                  echo $response->body;
                              }
              ))
          ->add('GET', 'http://google.cn',array(), array(
                  'timeout' => 3,
                  'callback' => function (Response $response) {
                                  echo $response->body;
                              }
              ))    
	      ->sendAll();