PHP code example of andhikayuana / curl-lib

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

    

andhikayuana / curl-lib example snippets




$curl = new \Yuana\Curl();

$res = $curl->get('http://api.halo.com/users');

// using query
// http://api.halo.com/users?users_id=2
$res = $curl->get('http://api.halo.com/users', [
    'users_id' => 2
]);

$res = $curl->post('http://api.halo.com/login', [
    'username' => 'yuana',
    'password' => 'yourpassword'
]);

$res = $curl->put('http://api.halo.com/users', [
    'users_id' => 3,
    'users_name' => 'Yuana Andhika',
    'users_dept' => 'Android Developer'
]);

$res = $curl->delete('http://api.halo.com/users', [
    'users_id' => 3
]);

$res = $curl->upload('http://api.domain.com/upload', [
    'fieldA' => '/path/to/file/fileA.jpg',
    'fieldB' => '/path/to/file/fileB.jpg',
]);

//override timeout [default 30]
$curl->timeout = 25;

//override redirection [default true]
$curl->isRedirect = false;

//override user agent [default from http user agent]
$curl->userAgent = 'Android App 1.1';

//override headers
$curl->headers = [
    'Authorization' => 'Bearer yourtokenhere'
];