PHP code example of downshiftorg / wp-http

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

    

downshiftorg / wp-http example snippets




use DownShift\WordPress\Http\Request;

$request  = new Request();
$response = $request->get('http://api.yolo.com/status');

$response->getStatusCode(); // (int)    200
$response->getBody();       // (string) '{"msg": "You only live once!"}'
$response->json();          // (array)  ['msg' => 'You only live once!']

$request->post('http://api.yolo.com/neckbeard', ['foo' => 'bar']);

$request->postJson('http://api.yolo.com/neckbeard', [
    'foo' => 'bar',
    'jim' => 'jam',
]);