1. Go to this page and download the library: Download uhura2/uhura 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/ */
uhura2 / uhura example snippets
$github = new Uhura('https://api.github.com');
$response = $github->users->colindecarlo->repos->get();
$uhura = new Uhura('http://someapi.com');
$response = $uhura->users->get();
$uhura = new Uhura('http://someapi.com');
$response = $uhura->users(1)->get();
$uhura = new Uhura('http://someapi.com');
$response = $uhura->users(1)->blogs('some-blog')->comments->get();
$uhura = new Uhura('http://someapi.com');
$uhura->users->create(['email' => '[email protected]']);
$uhura = new Uhura('http://someapi.com');
$response = $uhura->users->get();
$uhura = new Uhura('http://someapi.com');
$uhura->users(1)->update(['name' => 'John Doe']);
$uhura = new Uhura('http://someapi.com');
$uhura->users(1)->delete();
$uhura = new Uhura('https://someapi.com');
$uhura->useBasicAuthentication('someuser', 'somepassword');
$uhura->user->update(['email' => '[email protected]']);
$uhura = new Uhura('https://someapi.com');
$uhura->authenticate('Bearer somebearertoken');
$uhura->user->update(['email' => '[email protected]']);
// XML Response Handler
class XmlHandler
{
public function handle($response)
{
return new SimpleXMLElement($response->getBody()->getContents());
}
}
$uhura = new Uhura('https://someapi.com');
$uhura->useResponseHandler(new XmlHandler);
echo (string)($uhura->users(1)->get());
/*
<?xml version='1.0' standalone='yes'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.