Bitcoin Forum
December 11, 2024, 07:43:15 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bitcoin PHP json rpc error "JSON value is not an integer as expected"  (Read 208 times)
btctousd81 (OP)
Sr. Member
****
Offline Offline

Activity: 434
Merit: 270


View Profile WWW
January 03, 2018, 12:01:02 AM
Last edit: January 03, 2018, 01:32:13 AM by btctousd81
 #1

i am trying to connect to my local bitcoind using php json library https://github.com/aceat64/EasyBitcoin-PHP specified in https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP


i am trying to get block data. e.g.

Code:
$bitcoin = new Bitcoin('user','password');
$blockhash = $bitcoin->getblockhash('502284') ;


i am getting

JSON value is not an integer as expected


on further debuggng


$curl_error = curl_error($curl);

Code:
(
    [result] =>
    [error] => Array
        (
            [code] => -1
            [message] => JSON value is not an integer as expected
        )

    [id] => 1
)


this happens only with blockheight 502284 and not with other blocks.,

if i do this in command line using bitcoin-cli , then i can get proper output.,

but calling from php json/rpc i am getting warning and no result.

how can i fix this ? thanks for your time.[/code]

EDIT 1 :

on further inspection it seems this is only affected to

getblockhash

as it returns output in int instead of string., and while json doesnt works properly if int starts with 0 ., so it gives warning .,

thats what i think.

EDIT 2 :

if i do this

Code:

[root@localhost ]# curl --user user:password --data-binary '{"id":"curltest", "method": "getblockhash", "params": [502284] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
{"result":"0000000000000000001345b1216c6dfa6e3bdd2774d67c7a85ea6552e2245c08","error":null,"id":"curltest"}


i am getting proper output, so its not issue with bitcoind., but looks like php library.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!