PHP Classes

File: examples/post_json_request.php

Recommend this page to a friend!
  Classes of Unay Santisteban   PHP REST Client Class   examples/post_json_request.php   Download  
File: examples/post_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: 5 years ago
Size: 559 bytes


Class file image Download

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

try {

$api = new \OtherCode\Rest\Rest();
$api->configuration->url = "";
$api->configuration->addHeader('some_header', 'some_value');


$payload = new stdClass();
$payload->userId = 3400;
$payload->title = "Some title";
$payload->body = "Some test data";

$response = $api->post("posts/", $payload);

} catch (\
Exception $e) {