PHP code example of preprio / laravel-rest-sdk
1. Go to this page and download the library: Download preprio/laravel-rest-sdk 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/ */
preprio / laravel-rest-sdk example snippets
use Preprio\Prepr;
$apiRequest = new Prepr;
$apiRequest
->path('publications')
->query([
'fields' => 'items'
])
->get();
if($apiRequest->getStatusCode() == 200) {
print_r($apiRequest->getResponse());
}
use Preprio\Prepr;
$apiRequest = new Prepr;
$apiRequest
->path('publications/{id}', [
'id' => '1236f0b1-b26d-4dde-b835-9e4e441a6d09'
])
->query([
'fields' => 'items'
])
->get();
if($apiRequest->getStatusCode() == 200) {
print_r($apiRequest->getResponse());
}
$apiRequest = (new Prepr)
->path('publications')
->query([
'limit' => 200 // optional
])
->autoPaging();
if($apiRequest->getStatusCode() == 200) {
dump($apiRequest->getResponse());
}
$apiRequest = (new Prepr)
->path('publications')
->params([
'body' => 'Example'
])
->post();
if($apiRequest->getStatusCode() == 201) {
dump($apiRequest->getResponse());
}
$apiRequest = (new Prepr)
->path('publications')
->params([
'body' => 'Example'
])
->put();
if($apiRequest->getStatusCode() == 200) {
dump($apiRequest->getResponse());
}
$apiRequest = (new Prepr)
->path('publications')
->params([
'body' => 'Example'
])
->patch();
if($apiRequest->getStatusCode() == 200) {
dump($apiRequest->getResponse());
}
$apiRequest = (new Prepr)
->path('publications/{id}',[
'id' => 1
])
->delete();
if($apiRequest->getStatusCode() == 204) {
// Deleted.
}
use Illuminate\Support\Facades\Storage;
$source = Storage::readStream('image.jpg');
$apiRequest = (new Prepr)
->path('assets')
->params([
'body' => 'Example',
])
->file($source);
if($apiRequest->getStatusCode() == 200) {
dump($apiRequest->getResponse());
}
use Illuminate\Support\Facades\Storage;
$source = Storage::get('image.jpg');
$apiRequest = (new Prepr)
->path('assets')
->params([
'body' => 'Example',
])
->file($source, 'image.jpg');
if($apiRequest->getStatusCode() == 200) {
dump($apiRequest->getResponse());
}
php artisan vendor:publish --provider="Preprio\PreprServiceProvider"
text
PREPR_CACHE=true
PREPR_CACHE_TIME=1800
text
PREPR_TIMEOUT=30
PREPR_CONNECT_TIMEOUT=10