-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) 
0

1 Answer 1

-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)); ?> 
Sign up to request clarification or add additional context in comments.

2 Comments

same return value of bool(false). Maybe my username and password need to be in commas?
I edited my answer. Try again please

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.