Hi Bitcoin-Community,
i think the JSONRPC-PHP Classes are bad to use because of wired error-messages on problems.
So i present my variant to use jsonrpc in php.
[code]
<?php
function my_curl_request($url, $post_data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 'content-type: text/plain;');
curl_setopt($ch, CURLOPT_TRANSFERTEXT, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, false);
// decode result
$result = @curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
// CURL Variant
$url = "http://user:password@127.0.0.1:8332/";
$post_data = array("jsonrpc" => "1.0", "id"=>"curltest", "method"=> "getaccountaddress", "params"=>array(""));
$post_data = json_encode($post_data);
$result = my_curl_request($url, $post_data);
print_r($result)."\n";
$post_data = array("jsonrpc" => "1.0", "id"=>"curltest", "method"=> "getaccountaddress");
$post_data = json_encode($post_data);
$result = my_curl_request($url, $post_data);
print_r($result)."\n";
If i have time i could build a class around it.