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: 2 months 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";


For more information send a message to info at phpclasses dot org.