PHP code example of spruce-bruce / curl

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

    

spruce-bruce / curl example snippets


//set the url
$url = "http://somefictionaldomain.com/api";

//set the POST vars
$data = array(
    'query' => 'active',
    'page' => 3,
    'count' => 10
);

//get the post response
$response = Curl::post($url, $data);

//set the url
$url = "http://somefictionaldomain.com/api";

//set the GET vars
$data = array(
    'query' => 'active',
    'page' => 3,
    'count' => 10
);

//set addtional curl options
$options = array(
    CURLOPT_FAILONERROR => true
);

//get the GET response
$response = Curl::get($url, $data, $options);