1. Go to this page and download the library: Download softiciel/php-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/ */
softiciel / php-rest-client example snippets
sh
$url = 'http://www.example.com';
$getMethod = new Get($url);
$result = $getMethod->execute();
print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'.
sh
$url = 'https://httpbin.org/post';
$postMethod = new Post($url);
$postMethod->setParameter('text', 'Read these tips to improve');
$result = $postMethod->execute();
print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'.
sh
$url = 'https://httpbin.org/put';
$putMethod = new Put($url);
$data = 'Test data';
$result = $putMethod->execute($data);
print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'.
sh
$url = 'http://www.example.com';
$headMethod = new Head($url);
$result = $headMethod->execute();
print_r($result); // Will print the array with keys 'status', 'time', 'header', and 'error'.
sh
$url = 'http://www.example.com';
$optionsMethod = new Options($url);
$result = $optionsMethod->execute();
print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'
sh
$url = 'https://httpbin.org/DELETE';
$deleteMethod = new Delete($url);
$result = $deleteMethod->execute();
print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'
sh
$url = 'http://www.example.com';
$customMethod = new CustomMethod($url);
$result = $customMethod->execute('EXECUTE');
print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'
sh
$result = RestClient::execute([
'method' => 'get',
'url' => 'www.example.org'
]);
print_r($result); // Will print the array with keys 'status', 'time', 'header', 'body' and 'error'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.