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
Ronald Wiplinger
2,2233 gold badges17 silver badges22 bronze badges
1 Answer 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
prasanth
22.6k4 gold badges33 silver badges57 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-php