Bitcoin Forum
July 04, 2024, 07:00:30 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: problem for the RPC php curl code:  (Read 399 times)
supercanada1 (OP)
Sr. Member
****
Offline Offline

Activity: 798
Merit: 253


View Profile
June 03, 2015, 10:41:19 PM
 #1

$data_string = '{
        "jsonrpc": "1.0",
        "method": "getinfo",
        "id": "curltext",
        "params": {
        }
      }';



$ch = curl_init('http://username:password@MyNodeIPAddress:23741');                                                                     
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                     
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                         
'Content-Type: application/json',                                                                               
'Content-Length: ' . strlen($data_string))                                                                       
);                                                                                                                   

$result = curl_exec($ch);

echo $result;


I try to above PHP code, use RPC to call the node IP and getinfo from the NODE of the altcoin, no response, what is the problem?
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
June 04, 2015, 12:29:06 AM
 #2

$data_string = '{
        "jsonrpc": "1.0",
        "method": "getinfo",
        "id": "curltext",
        "params": {
        }
      }';



$ch = curl_init('http://username:password@MyNodeIPAddress:23741');                                                                     
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                     
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                         
'Content-Type: application/json',                                                                               
'Content-Length: ' . strlen($data_string))                                                                       
);                                                                                                                   

$result = curl_exec($ch);

echo $result;


I try to above PHP code, use RPC to call the node IP and getinfo from the NODE of the altcoin, no response, what is the problem?

Just a suggestion: you could simplify the testing by using curl on the command line to make sure the RPC server is up and listening.  Then, if that works, you know the issue is in your PHP module.
elbandi
Hero Member
*****
Offline Offline

Activity: 525
Merit: 529


View Profile
June 04, 2015, 03:47:36 PM
 #3

Add this:
Code:
curl_setopt($ch, CURLOPT_VERBOSE, true);
and curl will show what's going on.
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!