coinhive-example/api.php

20 lines
561 B
PHP
Raw Permalink Normal View History

2017-10-06 19:32:01 +02:00
<?php
2017-10-09 15:49:08 +02:00
require_once 'config.php';
$secret = $COINHIVE_SECRET;
2017-10-06 19:32:01 +02:00
$response = array();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://api.coinhive.com/user/top?secret='.$secret.'&count=10'
));
$result = curl_exec($curl);
$json = json_decode($result,true);
foreach($json['users'] as $i => $values){
$username = htmlentities($values['name']);
$response[$values['name']] = htmlentities($values['total']);
}
header('Content-Type: application/json');
echo json_encode($response);
curl_close($curl);