Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP class for the Coinhive HTTP API
<?php
class CoinHiveAPI {
const API_URL = 'https://api.coinhive.com';
private $secret = null;
public function __construct($secret) {
if (strlen($secret) !== 32) {
throw new Exception('CoinHive - Invalid Secret');
}
$this->secret = $secret;
}
function get($path, $data = []) {
$data['secret'] = $this->secret;
$url = self::API_URL.$path.'?'.http_build_query($data);
$response = file_get_contents($url);
return json_decode($response);
}
function post($path, $data = []) {
$data['secret'] = $this->secret;
$context = stream_context_create([
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
]
]);
$url = SELF::API_URL.$path;
$response = file_get_contents($url, false, $context);
return json_decode($response);
}
}
@marqueis301

This comment has been minimized.

marqueis301 commented Dec 20, 2017

26 hashes/s é D +++++

@marqueis301

This comment has been minimized.

marqueis301 commented Dec 20, 2017

achei um ele é ótimo

@cryonix33

This comment has been minimized.

cryonix33 commented Apr 11, 2018

Как я понял, то если выключить ПК, то все намайненные Монеро пропадут. Как же быть? У меня ПК потребляет энергии больше, чем здесь я заработаю если не выключать его никогда.

@taweesakteejantuk66

This comment has been minimized.

taweesakteejantuk66 commented Nov 3, 2018

good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment