1. Go to this page and download the library: Download ernandesrs/requester 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/ */
ernandesrs / requester example snippets
use ErnandesRS\Requester\Requester;
aceholder.typicode.com/guide/
*
*/
/**
* Requisição GET
* Buscando um post
*/
echo "\n\Obter post\n";
print_r(Requester::get("https://jsonplaceholder.typicode.com/posts/1"));
/**
* Requisição POST
* Criando um post
*/
$body = json_encode([
"title" => "Título top",
"body" => "Corpo massa deste post de título maneiro",
"userId" => 1
]);
$headers = [
'Content-type: application/json; charset=UTF-8',
];
echo "\n\nCriar post\n";
print_r(Requester::post("https://jsonplaceholder.typicode.com/posts", $body, $headers));
/**
* Requisição PUT
* Atualizando um post
*/
$body = json_encode([
"id" => 1,
"title" => "Novo título",
"body" => "Opa, conteúdo do post atualizado",
"userId" => 1
]);
$headers = [
'Content-type: application/json; charset=UTF-8',
];
echo "\n\nAtualizar post\n";
print_r(Requester::put("https://jsonplaceholder.typicode.com/posts/1", $body, $headers));
/**
* Requisição PATCH
* Atualizando parcialmente um post
*/
$body = json_encode([
"body" => "Opa, conteúdo do post atualizado parcialmente"
]);
$headers = [
'Content-type: application/json; charset=UTF-8',
];
echo "\n\nAtualizar parcialmente post\n";
print_r(Requester::patch("https://jsonplaceholder.typicode.com/posts/1", $body, $headers));
/**
* Requisição DELETE
* Deletando um post
*/
echo "\n\nDeletar post\n";
print_r(Requester::delete("https://jsonplaceholder.typicode.com/posts/1"));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.