Advertisement
Guest User

sendmany json failed

a guest
Feb 20th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2.  
  3. function sendMany()
  4.     {
  5.         $url = "http://127.0.0.1:48332";
  6.         $addr = "ztYmK4E...."  
  7.                
  8.         $param = array(
  9.             "address" => "ztSc...",
  10.             "amount" => 0.05
  11.             );
  12.         $json_encoded_param = json_encode($param);
  13.        
  14.         $data = array(
  15.                      "jsonrpc" => "1.0",
  16.                      "method" => "z_sendmany",
  17.                      "params" => array($addr,array($json_encoded_param)),
  18.                      "id" => "curltest"
  19.                      );
  20.         $json_encoded_data = json_encode($data);
  21.        
  22.         $handle = curl_init($url);                                                                      
  23.         curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "POST");                                                                    
  24.         curl_setopt($handle, CURLOPT_POSTFIELDS, $json_encoded_data);                                                                  
  25.         curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);                                                                      
  26.         curl_setopt($handle, CURLOPT_HTTPHEADER, array(                                                                          
  27.                                                 'Content-Type: application/json',                                                                                
  28.                                                 'Content-Length: ' . strlen($json_encoded_data))                                                                      
  29.         );                                                                                                                  
  30.        
  31.         $result = json_decode(curl_exec($handle));
  32.         curl_close($handle);
  33.            
  34.         return $result;
  35.     }
  36.    
  37. sendMany();
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement