PHP code example of nguyenanhung / requests

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

    

nguyenanhung / requests example snippets



nguyenanhung\MyRequests\MyRequests;

$requests = new MyRequests();



nguyenanhung\MyRequests\MyRequests;
$requests = new MyRequests();


nguyenanhung\MyRequests\MyRequests;
$requests = new MyRequests();

echo $requests->getVersion(); // Print: 1.0.14


guyenanhung\MyRequests\MyRequests;

$debug                    = [
    'debugStatus'     => TRUE,
    'debugLoggerPath' => testLogPath()
];
$url                      = 'https://httpbin.org/';
$data                     = [
    'date'    => date('Y-m-d'),
    'service' => 'ME',
    'token'   => 'empty'
];
$method                   = 'GET';
$headers                  = [];
$options                  = [];
$request                  = new MyRequests();
$request->debugStatus     = TRUE;
$request->debugLoggerPath = '/your/to/path/save_log';
$request->__construct();
$request->setHeader($headers);
$request->setOptions($options);

echo $request->getVersion(); // Print: 0.1.3.4

$guzzlePhpRequest = $request->guzzlePhpRequest($url, $data, $method);
d($guzzlePhpRequest);

$curlRequest = $request->curlRequest($url, $data, $method);
d($curlRequest);

$sendRequest = $request->sendRequest($url, $data, $method);
d($sendRequest);


guyenanhung\MyRequests\GetContents;

// Test Data
$url    = 'https://httpbin.org/';
$data   = [
    'date'    => date('Y-m-d'),
    'service' => 'ME',
    'token'   => 'empty'
];
$method = 'GET';
// Let's Go
$content = new GetContents();
$content->setURL($url);
$content->setMethod($method);
$content->setData($data);
$content->sendRequest();

echo $content->getVersion(); // Print: 0.1.3.4

$response   = $content->response();
$getContent = $content->getContent();
$getError   = $content->getError();

d($response);
d($getContent);
d($getError);


guyenanhung\MyRequests\SoapRequest;

$soap                  = new SoapRequest();
$soap->debugStatus     = true;
$soap->debugLoggerPath = '/your/to/path/save_log';
$soap->__construct();
$soap->setEndpoint('url');
$soap->setCallFunction('function');
$soap->setData($data);
$result = $soap->clientRequestWsdl();

echo $soap->getVersion(); // Print: 0.1.3.4
d($result);