PHP code example of efremovp / simple-curl

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

    

efremovp / simple-curl example snippets


use efremovP\curl\Curl;

//example send POST request with empty headers
$url = 'https://api.example.com/login/';

$params = [
    'api_key' => 'sfq324fszdfasdf',
    'username' => 'test',
    'password' => 'sekret'
];
$result = Curl::send($url, [], $params);

//example send POST request with header
$url = 'https://api.example.com/login/'

$header = ['Authorization: Bearer sfq324fszdfasdf123456'];

$params = [
    'api_key' => 'sfq324fszdfasdf',
    'email' => '[email protected]'
];

$result = Curl::send($url, $header, $params);

//example send GET request
$url = 'https://api.example.com/get/'

$result = Curl::send($url, [], null, 'get');

php composer.phar