Package EOL
This package is archived because of discontinuation of CoinHive., (*1)
PHP and Laravel 5 CoinHive API and Captcha
![Software License][ico-license]
, (*2)
PHP and Laravel 5 CoinHive API and Captcha, (*3)
Install
Via Composer, (*4)
$ composer require kduma/coinhive-api
Usage
$api = new \KDuma\CoinHive\CoinHiveApi(YOUR_SITE_KEY, YOUR_SECRET_KEY);
$api->getPayoutStats();
$api->getSiteStats();
$api->withdrawFromUser($name, $amount);
$api->getUserBalance($name);
$api->getTopUsers($count = 128);
$api->getUsersList($page = null, $count = 4096);
$api->createLink($url, $hashes = 256);
$api->resetUser($name);
$api->resetAllUsers();
$api->verifyToken($token, $hashes = 256);
Laravel Usage
Setup
In Laravel 5.5, service provider is automatically discovered. If you don't use package discovery,
add the Service Provider to the providers array in config/app.php:, (*5)
KDuma\CoinHive\Laravel\CoinHiveServiceProvider::class,
Add following entries to your .env file:, (*6)
COINHIVE_SITE_KEY=<your site key>
COINHIVE_SECRET_KEY=<your secret key>
COINHIVE_DEFAULT_HASHES_COUNT=512
Add following entries to your config\services.php file:, (*7)
'coinhive' => [
'default_hashes' => env('COINHIVE_DEFAULT_HASHES_COUNT', 512),
'site_key' => env('COINHIVE_SITE_KEY'),
'secret_key' => env('COINHIVE_SECRET_KEY'),
'use_authedmine_url' => true,
],
Usage
You can resolve CoinHiveApi::class class:
``` php
use KDuma\CoinHive\CoinHiveApi;, (*8)
$api = app(CoinHiveApi::class);, (*9)
$top_users = $api->getTopUsers();, (*10)
or You can use injection container
``` php
use KDuma\CoinHive\CoinHiveApi;
Route::get('/api', function (CoinHiveApi $api) {
$top_users = $api->getTopUsers();
});
In your form, place Captcha field using CoinHiveCaptchaDisplayer class:, (*11)
{!! resolve(\KDuma\CoinHive\CoinHiveCaptchaDisplayer::class)->display() !!}
You can also specify more options like required_hashes, autostart, whitelabel or disable-elements
like the following example:, (*12)
{!! resolve(\KDuma\CoinHive\CoinHiveCaptchaDisplayer::class)->display(256, [
'data-autostart' => false,
'data-whitelabel' => false,
'data-disable-elements' => "#submit",
]) !!}
To check if the Captcha is valid you can use ValidateCoinHiveCaptchaToken validator:, (*13)
Route::post('/post', function (\Illuminate\Http\Request $request) {
$request->validate([
'coinhive-captcha-token' => new \KDuma\CoinHive\Laravel\ValidateCoinHiveCaptchaToken()
]);
});
If you need custom required_hashes number, you can pass it in the constructor., (*14)
Credits
License
The MIT License (MIT). Please see License File for more information., (*15)