PHP code example of lemmon / fetch

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

    

lemmon / fetch example snippets


// plain GET request
$res = fetch('http://uuid.lemmonjuice.com/');
$body = $res->body(); // returns response body
// get JSON data
$json = fetch('http://uuid.lemmonjuice.com/', [
  'headers' => [
    'Accept' => 'application/json',
  ],
])->json();
// POST data
$res = fetch('http://httpbin.org/post', [
  'method' => 'POST',
  'headers' => [
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
  ],
  'json' => [
    'hello' => 'world',
  ],
]);

Fetch\Response fetch(string $resource, array $init = NULL)