2017 © Pedro Peláez
 

library coinhive-api

PHP and Laravel 5 CoinHive API and Captcha

image

kduma/coinhive-api

PHP and Laravel 5 CoinHive API and Captcha

  • Tuesday, January 23, 2018
  • by kduma
  • Repository
  • 3 Watchers
  • 12 Stars
  • 115 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

Package EOL

This package is archived because of discontinuation of CoinHive., (*1)

PHP and Laravel 5 CoinHive API and Captcha

Latest Version on Packagist ![Software License][ico-license] Total Downloads, (*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();
});

Using CoinHive Proof of Work Captcha with Laravel

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)

The Versions

23/01 2018

dev-master

9999999-dev https://github.com/kduma-OSS/L5-CoinHiveApi

PHP and Laravel 5 CoinHive API and Captcha

  Sources   Download

MIT

The Requires

 

laravel kduma coinhive

23/01 2018

v1.1.1

1.1.1.0 https://github.com/kduma-OSS/L5-CoinHiveApi

PHP and Laravel 5 CoinHive API and Captcha

  Sources   Download

MIT

The Requires

 

laravel kduma coinhive

22/01 2018

v1.1

1.1.0.0 https://github.com/kduma-OSS/L5-CoinHiveApi

PHP and Laravel 5 CoinHive API and Captcha

  Sources   Download

MIT

The Requires

 

laravel kduma coinhive

05/10 2017

v1.0

1.0.0.0 https://github.com/kduma-OSS/L5-CoinHiveApi

PHP and Laravel 5 CoinHive API and Captcha

  Sources   Download

MIT

The Requires

 

laravel kduma coinhive