1. Go to this page and download the library: Download bonuscred/rest-client 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/ */
$res = new RestClient\Request::run('https://api.github.com/repos/dnlfranklin/rest-client', 'GET'); // Objeto Response
$req = new RestClient\Request;
// Callback chamado em caso em requisições bem sucedidas
$req->onSuccess(function(Response $response){
echo 'Success: '.$response->get_http_code();
});
// Callback chamado em caso de erro de requisição
$req->onError(function(Response $response){
echo 'Error: '.$response->get_errmessage();
});
// Callback chamado após finalização de requisição
$req->onComplete(function(Response $response){
echo $response->get_body();
});
$res = $req->get('https://api.github.com/repos/dnlfranklin/rest-client');
$res = new RestClient\Request::run('https://api.github.com/repos/dnlfranklin/rest-client');
$data = $res->get_data(); // Array de atributos recebidos no formato json
$res = new RestClient\Request::run('https://api.github.com/repos/dnlfranklin/rest-client');
$data = $res->decode(function($body){
//Tratamento específico de decode
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.