BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bitcoinrpc.class.php 969B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. class BitcoinRpc
  3. {
  4. public static function __callStatic($Method, $Args)
  5. {
  6. if (!defined('BITCOIN_RPC_URL')) {
  7. return false;
  8. }
  9. $MessageID = mt_rand();
  10. $Params = json_encode(
  11. array(
  12. 'method' => $Method,
  13. 'params' => $Args,
  14. 'id' => $MessageID
  15. )
  16. );
  17. $Request = array(
  18. 'http' => array(
  19. 'method' => 'POST',
  20. 'header' => 'Content-type: application/json',
  21. 'content' => $Params
  22. )
  23. );
  24. if (!$Response = file_get_contents(BITCOIN_RPC_URL, false, stream_context_create($Request))) {
  25. return false;
  26. }
  27. $Response = json_decode($Response);
  28. if ($Response->id != $MessageID || !empty($Response->error) || empty($Response->result)) {
  29. return false;
  30. }
  31. return $Response->result;
  32. }
  33. }