Bitcoin Forum
October 22, 2017, 04:16:14 PM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: JSON RPC API call from webpage  (Read 777 times)
carlosdelagarza
Newbie
*
Offline Offline

Activity: 21


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?

Free satoshis! http://freesatoshis.esy.es
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
fikihafana
Sr. Member
****
Offline Offline

Activity: 462



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

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

Activity: 1106


head of customer success @ bustabit


View Profile WWW
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.

bustabit.com :: The social bitcoin gambling site
carlosdelagarza
Newbie
*
Offline Offline

Activity: 21


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/

http://i.imgur.com/XRocWqL.jpg

Free satoshis! http://freesatoshis.esy.es
carlosdelagarza
Newbie
*
Offline Offline

Activity: 21


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.

Free satoshis! http://freesatoshis.esy.es
cloverme
Legendary
*
Offline Offline

Activity: 1204


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
Sr. Member
****
Offline Offline

Activity: 462



View Profile
January 30, 2017, 03:50:11 PM
 #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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!