PHP code example of missing-u / simple-request

1. Go to this page and download the library: Download missing-u/simple-request 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/ */

    

missing-u / simple-request example snippets


        $url = 'http://mock.server.com/echo';
        
        $illumination = '请求说明';
        
        $info = SimpleRequest::json_get($illumination, $url); // [ "echo" => "echo" ]
        

      $url = 'http://mock.server.com/echo/params/reflect';
      
      $illumination = '请求说明';

      $params = [
          'user' =>
              [
                  'name' => 'yang',
                  'age'  => 10,
              ],
      ];

     $info = SimpleRequest::json_get($illumination, $url, $params); 
      
     $this->assertTrue(
        $info == $params
     );
      

        $url = 'http://mock.server.com/echo';
        
        $illumination = '请求说明';
        
        $info = SimpleRequest::json_post($illumination, $url); // [ "echo" => "echo" ]
        

      $url = 'http://mock.server.com/echo/params/reflect';
      
      $illumination = '请求说明';

      $params = [
          'user' =>
              [
                  'name' => 'yang',
                  'age'  => 10,
              ],
      ];

     $info = SimpleRequest::json_post($illumination, $url, $params); 
      
     $this->assertTrue(
        $info == $params
     );