PHP code example of mosquitood / curl

1. Go to this page and download the library: Download mosquitood/curl 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/ */

    

mosquitood / curl example snippets



$request = new Mosquitood\Curl\Curl;
$request->get('https://www.baidu.com");
$request->response;


$request = new Mosquitood\Curl\Curl;
$request->post('https://www.example.com", array('k1' => 'v1', 'k2' => 'v1'), $json = true/false);
$request->response; //response 未处理
$request->error; //是否出错
$request->errorCode; //错误码
$request->errorMsg; //错误信息
$request->requestHeader; //请求头
$request->responseHeader; //响应头

$url = array(
  'k1' => 'url1',
  'k2' => 'url2',
);
$data = array(
  'k1' => array('v1' => 'v11'),
  'k2' => array('v2' => 'v22')
);
$request->post($url, $data);
$request->response[$url];