2

I am wondering if its possible to use curl to getinfo from the bitcoin server thanks.

<?php
// init the resource
$ch = curl_init();

// set a single option...
$username = 'usernamefromconfig';
$pwd = 'passwordfromconfig';

curl_setopt_array(
    $ch, array( 
    CURLOPT_URL => "$username:$pwd@127.0.0.1:8336",
    CURLOPT_RETURNTRANSFER => true
));

$output = curl_exec($ch);
echo $output;

// free
curl_close($ch);
?>
3

You can use the command-line curl or any of the various JSON-RPC examples listed here.

In particular, you can use curl like this:

$ curl --user <username>:<password> --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

For PHP, you can use this library and do:

require_once 'jsonRPCClient.php';

$bitcoin = new jsonRPCClient('http://user:password@127.0.0.1:8332/');

echo "<pre>\n";
print_r($bitcoin->getinfo()); echo "\n";
echo "Received: ".$bitcoin->getreceivedbylabel("Your Address")."\n";
echo "</pre>";

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.