PHP code example of jowy / rest-client
1. Go to this page and download the library: Download jowy/rest-client 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/ */
jowy / rest-client example snippets
estClient\CurlRestClient;
$curl = new CurlRestClient();
$curl->setOptions([CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0]);
var_dump($curl->executeQuery('http://www.google.com'));
// OR....
$curl = new CurlRestClient('http://www.google.com',
array( // Header data
'X-API-KEY: 16251821972',
'OUTPUT: JSON'
),
array( // AUTH (curl)
'CURLOPT_HTTPAUTH' => CURLAUTH_DIGEST,
'username' => 'root',
'password' => 'toor'
),
array(
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0
)
);
$curl->executeQuery('http://api.somewebsite.com',
'POST',
array(
'X-API-KEY: 16251821972',
'OUTPUT: JSON'
),
array(
'USERNAME' => 'jowy',
'SERVERID' => '192882'
),
array(
'CURLOPT_HTTPAUTH' => CURL_AUTH_DIGEST,
'username' => 'jowy',
'password' => '123456'
)
);
// OR USE CONVENIENT METHODS
// GET
$res = $curl->get('customer/details', array(
'customerId' => 55
));
// POST
$res = $curl->post('customer', array(
'name' => 'Ole Nordmann',
'age' => 49,
'address' => 'Stortingsveien 5',
'zip' => '0120',
'city' => 'Oslo'
));