-1

have an electrum wallet on my linux server. Am trying to run commands to control it through php.

Electrum essentially says, use curl and get a json returned.

http://docs.electrum.org/en/latest/merchant.html Last section

Below is what I have so far it is not working.

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://myuserame:mypassword==@serverip:7777");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"id\":\"curltext\",\"method\":\"getbalance\",\"params\":[]}");

$result = curl_exec($ch);

if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); }
curl_close ($ch);

var_dump($result);

?>

Returns:

Error:bool(false)
seamus
  • 2,681
  • 7
  • 26
  • 49

1 Answers1

-1

EDIT:

Try like this:

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://serverip:7777");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST , 1);
curl_setopt($ch, CURLOPT_USERPWD , 'myuserame:mypassword');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"id\":\"curltext\",\"method\":\"getbalance\",\"params\":[]}");

$result = curl_exec($ch);

//if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); }
//curl_close ($ch);

dd(json_decode($result,1));

?>