Bitcoin Forum
May 12, 2024, 09:33:45 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: JSON RPC API call from webpage  (Read 914 times)
carlosdelagarza (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile WWW
January 28, 2017, 05:54:46 AM
 #1

Hello, I want to make API calls to my Bitcoin Core wallet from my webpage but when I try to connect it gives me Internal Server Error

I'm using easybitcoin.php JSON from https://github.com/aceat64/EasyBitcoin-PHP

I'm trying with this JSON RPC call:

Code:
<?php
require_once(
'easybitcoin.php');
        
$bitcoin = new Bitcoin('myusername','mypassword','myip','8332');
        
$bitcoin->getinfo();
?>


My bitcoin.conf file has:

Code:
listen=1
maxconnections=15
server=1
daemon=1
rpcuser=myusername
rpcpassword=mypassword
rpcclienttimeout=60
rpcport=8332
rpcallowip=0.0.0.0/0 (Before I put my IP address here but it didn't solve too)

When I use bitcoin-cli.exe client to send commands to my Bitcoin Core server via 127.0.0.1 (localhost) it works perfectly.

What I'm doing wrong?
1715549625
Hero Member
*
Offline Offline

Posts: 1715549625

View Profile Personal Message (Offline)

Ignore
1715549625
Reply with quote  #2

1715549625
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
fikihafana
Sr. Member
****
Offline Offline

Activity: 462
Merit: 250



View Profile
January 28, 2017, 02:51:02 PM
 #2

have you unblock ip or port address?
RHavar
Legendary
*
Offline Offline

Activity: 2557
Merit: 1886



View Profile
January 28, 2017, 10:50:00 PM
 #3

You need to log the actual error, probably a setting in PHP so you see what the 'internal error' is, not just that one exists. From there it'll make it a lot easier to find what's going wrong.

Check out gamblingsitefinder.com for a decent list/rankings of crypto casinos. Note: I have no affiliation or interest in it, and don't even agree with all the rankings ... but it's the only uncorrupted review site I'm aware of.
carlosdelagarza (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile WWW
January 29, 2017, 06:09:23 AM
 #4

have you unblock ip or port address?

I have opened my port.

I tested it on http://www.whatsmyip.org/port-scanner/

https://i.imgur.com/XRocWqL.jpg
carlosdelagarza (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile WWW
January 29, 2017, 06:51:58 AM
 #5

You need to log the actual error, probably a setting in PHP so you see what the 'internal error' is, not just that one exists. From there it'll make it a lot easier to find what's going wrong.

The error says

Quote
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.
cloverme
Legendary
*
Offline Offline

Activity: 1512
Merit: 1057


SpacePirate.io


View Profile WWW
January 30, 2017, 02:32:13 PM
 #6

Look in your httpd error log file, you should find more information there.

SELinux may be preventing access as well (to port or local files), you may want to check the logs.
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Working_with_SELinux-Which_Log_File_is_Used.html
nemgun
Hero Member
*****
Offline Offline

Activity: 882
Merit: 533



View Profile WWW
January 30, 2017, 03:50:11 PM
Last edit: January 30, 2017, 04:30:24 PM by nemgun
 #7

change rpcallowip = localhost or 127.0.0.1
you could also add more info to your querry, like the protocol, which is generally http :

Code:
<?php
require_once(
'easybitcoin.php');
        
$bitcoin = new Bitcoin('myusername','mypassword','myip','8332''http');
        
$bitcoin->getinfo();
        
// You can do a small test here
        
$test $bitcoin->getinfo();
        echo 
$test;

?>


.conf :

Code:
listen=1
maxconnections=15
server=1
daemon=1
rpcuser=myusername
rpcpassword=mypassword
rpcclienttimeout=60
rpcport=8332
rpcallowip=localhost or 127.0.0.1 (unless you want to query it from a remote computer, if so, just enter the ip address)

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!