PHP Classes

File: examples/github.php

Recommend this page to a friend!
  Classes of Lars Moelleken   PHP httpful Request   examples/github.php   Download  
File: examples/github.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP httpful Request
Send and process HTTP requests using handler class
Author: By
Last change:
Date: 4 years ago
Size: 429 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

// JSON Example via GitHub-API

require __DIR__ . '/../vendor/autoload.php';

$uri = 'https://api.github.com/users/voku';
$response = \Httpful\Client::get_request($uri)
    ->
withHeader('X-Foo-Header', 'Just as a demo')
    ->
expectsJson()
    ->
send();

$result = $response->getRawBody();

echo
$result['name'] . ' joined GitHub on ' . \date('M jS Y', \strtotime($result['created_at'])) . "\n";