1. Go to this page and download the library: Download neon-php/simple-http 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/ */
neon-php / simple-http example snippets
use Neon\Http\Facade\Http;
$response = Http::get('http://example.com/api');
use Neon\Http\Facade\Http;
$response = Http::addHeader('Accept', 'application/json')->post('/api');
use Neon\Http\Facade\Http;
$response = Http::bearer($token)->post('/api');
use Neon\Http\Facade\Http;
$image = $_FILES['image'];
$response = Http::file('image', $image['name', $image['tmp_name']])->post('/api');
use Neon\Http\Facade\Http;
$response = Http::get('http://example.com/api');
if ($response->hasHeader('Content-Length')) {
// Header Content-Length exists
}
$values = $response->getHeader('Content-Length');
$code = $response->code();
// Status code is 200, 201 or 204
$response->successfull();
// Status code is bigger than or equal to 400
$response->failure();
// Status code is bigger than or equal to 500
$response->serverError();
// Status code is bigger than or equal to 400 AND less than 500
$response->clientError();
// Status code is 201
$response->created();
// Status code is 204
$response->noContent();
// Status code is 404
$response->notFound();
// Status code is 401
$response->unauthorized();
// Status code is 403
$response->forbidden();
// Status code is 400
$response->badRequest();
$body = $response->body();
$body_stream = $response->bodyRaw();
use Neon\Http\Exceptions\RequestException;
try {
$body = $response->json();
} catch (RequestException $e) {
// Response body is not json
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.