0

On my Linux box I use a command:

lightning-cli getinfo

which gives me then JSON data.

I tried to use:

$jsonFile = "sh /bin/lightning-cli getinfo";
$jsondata = file_get_contents($jsonFile);
$data = json_decode($jsondata, true);

which gives me then: PHP Warning: file_get_contents(sh /bin/lightning-cli getinfo): failed to open stream: No such file or directory ...

How can I get the data into php?

asked Mar 23, 2019 at 16:04
0

1 Answer 1

1

Try shell_exec instead file_get_contents

$jsonFile = "sh /bin/lightning-cli getinfo";
$jsondata = shell_exec($jsonFile);
$data = json_decode($jsondata, true);

OR

Direct Call

 $jsonFile = "lightning-cli getinfo";
 $jsondata = shell_exec($jsonFile);
 $data = json_decode($jsondata, true);
answered Mar 23, 2019 at 16:06
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.