PHP Classes

File: examples/get_json_request.php

Recommend this page to a friend!
  Classes of Unay Santisteban   PHP REST Client Class   examples/get_json_request.php   Download  
File: examples/get_json_request.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP REST Client Class
Send REST request to a HTTP server
Author: By
Last change: Now the examples point to vendor/autoload.php
Date: 6 years ago
Size: 356 bytes
 

Contents

Class file image Download
<?php

require_once '../vendor/autoload.php';

try {

   
$api = new \OtherCode\Rest\Rest(new \OtherCode\Rest\Core\Configuration(array(
       
'url' => 'http://jsonplaceholder.typicode.com/',
    )));
   
$api->setDecoder("json");

   
$response = $api->get("posts/1");
   
var_dump($response);

} catch (\
Exception $e) {

    print
$e->getMessage();

}