Bitcoin Forum
June 22, 2024, 09:50:28 AM *
News: Voting for pizza day contest
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Another Method for PHP and jsonRPC on: July 06, 2011, 07:59:59 AM
Code:
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($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_HEADER'content-type: text/plain;');
        
curl_setopt($chCURLOPT_TRANSFERTEXT0);
        
curl_setopt($chCURLOPT_POSTFIELDS$post_data);
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt($chCURLOPT_PROXYfalse);

        
// decode result
        
$result = @curl_exec($ch);
        
curl_close($ch);

        return 
json_decode($resulttrue);
}

// 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";

and this are the results:
Code:
Array
(
    [result] => xxxxxx5vjjQ4KNP1Ke717qGXWiCCxxxxxx
    [error] =>
    [id] => curltest
)
Array
(
    [result] =>
    [error] => Array
        (
            [code ] => -1
            [message] => getaccountaddress <account>
Returns the current bitcoin address for receiving payments to this account.
        )

    [id] => curltest
)
[/code]

If i have time i could build a class around it.

What did you think? Is it better than jsonRPC-PHP?

Greetings Shuro
2  Other / Beginners & Help / Re: Introduce yourself :) on: July 05, 2011, 08:52:46 AM
Hi there, i'am an webmaster from germany and envelop a bitcoin-site
3  Other / Beginners & Help / Re: Bitcoin Rap hahaha ... on: July 05, 2011, 06:32:22 AM

Very nice  Grin Grin Grin
4  Other / Beginners & Help / Re: Whitelist Requests (Want out of here?) on: July 05, 2011, 06:31:44 AM
I didn't want to wait....and also i think this method only supports spam, the "Newbies" are spamming in this Board to become the privilege to write in the other forums
5  Other / Beginners & Help / Re: HOWTO: create a 100% secure wallet on: July 05, 2011, 06:29:29 AM
Thanks for this Howto!
6  Other / Beginners & Help / Re: Newbie restrictions on: July 05, 2011, 06:27:59 AM
I dont like this method, but i accept it  Roll Eyes
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!