basecardhero/randoms

A random.org api wrapper for php.

0.3.0 2020-07-31 01:43 UTC

This package is auto-updated.

Last update: 2024-10-29 05:59:23 UTC


README

Build Status codecov

This package was created for a project I am working on and does not fully support random.org services (or the way you may want it to). Feel free to add functionality by creating a pull request. See contributing.

Installation

You can install the package via composer:

$ composer require basecardhero/randoms

Usage

You will need to configure the Random.org API Key.

Examples

Create a client instance

require_once '/project/path/vendor/autoload.php';

$apiKey = '00000000-0000-0000-0000-0000000000';
$httpClient = new \BaseCardHero\Randoms\HttpClient();
$randomOrgClient = new \BaseCardHero\Randoms\RandomOrg\Client($apiKey, $httpClient);

generateSignedIntegers

$response = $randomOrgClient->generateSignedIntegers(5, 0, 4, false, 10, 'some-id');
echo get_class($response); // \Psr\Http\Message\ResponseInterface

You can get the json response with the following.

$json_response = json_decode((string) $response->getBody(), true);

See generateSignedIntegers for the respons structure.

getUsage

$response = $randomOrgClient->getUsage('some-id');
echo get_class($response); // \Psr\Http\Message\ResponseInterface

You can get the json response with the following.

$json_response = json_decode((string) $response->getBody(), true);

See getUsage for the respons structure.

Command line examples

Before using the command line examples, be sure to set your api key.

export RANDOM_ORG_API_KEY=00000000-0000-0000-0000-0000000000

generateSignedIntegers

php bin/generate-signed-integers.php

getUsage

php bin/get-usage.php

Testing

composer all

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email ryan@basecardhero.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.