PHP code example of arturmamedov / w-api

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

    

arturmamedov / w-api example snippets



$endpoint = 'blog/posts'; // relative to what set in $host and $version in MyApi Class
// so result: http://api.test/api/v1/blog/posts

# 1 - Include and init
 $response = [ 'status' => false, 'error' => 'CURL_ERR' ];
    exit(print_r($response)); // for debug reason, to remove in production
}else {
    $response = json_decode($json_response);
}

// Use $response ...
foreach ($response as $post){
    // do things with your resource
}