PHP code example of caiolandgraf / requestapi

1. Go to this page and download the library: Download caiolandgraf/requestapi 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/ */

    

caiolandgraf / requestapi example snippets




aioLandgraf\Api\RequestApi;

$request = new RequestApi("https://www.apiurl.com");

// login
$request->post([
    "login" => "[email protected]",
    "password" => "password"
], "login");

// read
$user = $request->get([
    "id" => "1"
], "user");

//update
$user->put([
    "first_name" => "Caio",
    "last_name" => "Landgraf",
    "genre" => "male",
    "datebirth" => "1980-01-02",
    "document" => "888888888"
], "user/update");

//test and result
if ($user->error()) {
    $user->error(); //object
} else {
    $user->response(); //object
}



aioLandgraf\Api\RequestApi;

$request = new RequestApi("https://www.form.com/contact");

$request->post([
    "name" => "Name",
    "email" => "[email protected]",
    "subject" => "Subject",
    "message" => "Message"
]);

//test and result
if ($request->error()) {
    $request->error(); //object
} else {
    $request->response(); //object
}