PHP code example of lliure / llrequest
1. Go to this page and download the library: Download lliure/llrequest 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/ */
lliure / llrequest example snippets
use ll\Request\Request;
// Set SOAP headers
$headers = [
'login' => 'xxxx',
'password' => 'xxxx',
'trace' => 1,
'exception' => 0
];
// Make a SOAP request
Request::soap('http://xxxxx/service.svc?wsdl')
->headers($headers)
->ProductGet(['idProduct' => 4])
->done(function ($response) {
echo '<pre>' , __LINE__ , ": " , print_r($response, true) , '</pre>';
});
use ll\Request\Request;
// Make an HTTP GET request
Request::http('http://xxxxx.xxx/xxx/xxx')
->headers([
'Content-Type' => 'application/json'
])
->get()
->done(function ($response) {
echo '<pre>' , __LINE__ , ": " , print_r($response->meta(), true) , '</pre>';
$decodedResponse = json_decode($response);
echo '<pre>' , __LINE__ , ": " , print_r($decodedResponse, true) , '</pre>';
});
use ll\Request\Request;
// Make an HTTP POST request
Request::http('http://xxxxx.xxx/xxx/xxx')
->headers([
'Content-Type' => 'application/json'
])
->post(json_encode(['name' => 'tintim']))
->done(function ($response) {
echo '<pre>' , __LINE__ , ": " , print_r($response->meta(), true) , '</pre>';
$decodedResponse = json_decode($response);
echo '<pre>' , __LINE__ , ": " , print_r($decodedResponse, true) , '</pre>';
});