PHP code example of uchm4n / api-client

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

    

uchm4n / api-client example snippets




\APIClient;

$api = new APIClient();

// test getPosts
$api->getPosts();

// test getPostByID
$api->getPostByID(1);

// test getPostWithComments
$api->getPostWithComments(1);

// test getCommentsByPost
$api->getCommentsByPost(5);

// test savePost
$api->savePost([
    'title'  => 'TEST SAVED',
    'body'   => 'TEST BODY',
    'userId' => 1,
]);

// test updatePost
$api->updatePost([
    'id'     => 1,
    'title'  => 'TEST UPDATED',
    'body'   => 'TEST BODY',
    'userId' => 1,
]);

// test patchPost
$api->patchPost([
    'id'    => 1,
    'title' => 'TEST PATCHED',
]);

// test deletePost
$api->deletePost(5);