coinhive-example/api.php

20 lines
561 B
PHP

<?php
require_once 'config.php';
$secret = $COINHIVE_SECRET;
$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);