test.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. function http_request_xml($url,$data = null,$arr_header = null){
  3. $curl = curl_init();
  4. curl_setopt($curl, CURLOPT_URL, $url);
  5. // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  6. // curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
  7. if (!empty($data)){
  8. curl_setopt($curl, CURLOPT_POST, 1);
  9. curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  10. }
  11. if(!empty($arr_header)){
  12. curl_setopt($curl, CURLOPT_HTTPHEADER, $arr_header);
  13. }
  14. curl_setopt($curl,CURLOPT_HEADER,1);
  15. // curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  16. $output = curl_exec($curl);
  17. // echo $output;
  18. curl_close($curl);
  19. unset($curl);
  20. return $output;
  21. }
  22. $url = "47.98.168.8:18082/json_rpc";
  23. $arr_header[] = "Content-Type:application/json";
  24. $arr_header[] = "Authorization: Basic ".base64_encode("monero:monero"); //添加头,在name和pass处填写对应账号密码
  25. $request = json_encode(array(
  26. 'method' => 'create_account',
  27. 'params' => array('label'=>'asddd'),
  28. 'id' => 0
  29. ));
  30. $res = http_request_xml($url,$request, $arr_header);
  31. ?>