PHP code example of jaredchu / jc-request

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

    

jaredchu / jc-request example snippets


use JC\HttpClient\JCRequest;

$response = JCRequest::get($url);
echo $response->status();
echo $response->body();
var_dump($response->json());

$response = JCRequest::post($url, $params, $headers);
echo $response->status();
echo $response->body();
var_dump($response->json());

$response = JCRequest::post($url, json_encode($params), $headers);
var_dump($response->json());

$response = JCRequest::get($url, $params, $headers, [
  'auth' => [$userName, $passwd]
]);

$response = JCRequest::get($url, $params, $headers, [
  'connect_timeout' => 2,
  'timeout' => 2
]);