PHP code example of snappmarket / php-rest-communicator
1. Go to this page and download the library: Download snappmarket/php-rest-communicator 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/ */
snappmarket / php-rest-communicator example snippets
use SnappMarket\Communicator\Communicator;
use Illuminate\Log\Logger; // This is just an example for laravel logger that implements LoggerInterface
$base_url = 'your_base_ur_here';
$headers = ['x-Foo'=>'Bar'];
$logger = new Logger();
$uri = 'your_uri_here';
$parameters = [
'page' => '2',
'sort' => 'desc'
]; // parameters array acts as querystring (https://foo.bar/?page=2&sort=desc)
try {
$communicator = new Communicator($base_url, $headers, $logger);
$response = $communicator->request(Communicator::METHOD_GET,$uri,$parameters, $headers);
} catch (Exception $exception){
throw $exception;
}
use SnappMarket\Communicator\Communicator;
use Illuminate\Log\Logger; // This is just an example for laravel logger that implements LoggerInterface
$base_url = 'your_base_ur_here';
$headers = ['x-Foo'=>'Bar', 'content-type'=>Communicator::APPLICATION_JSON];
$logger = new Logger();
$uri = 'your_uri_here';
$parameters = [
'phone_number' => '09xxxxxxxxx'
];
try {
$communicator = new Communicator($base_url, $headers, $logger);
$response = $communicator->request(Communicator::METHOD_POST,$uri,$parameters, $headers);
} catch (Exception $exception){
throw $exception;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.