Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['mysubmit'])){
- $data = $_POST['data'];
- $address = $_POST['address'];
- $url='http://192.168.43.70:8374/';
- $data = bin2hex($data);
- echo $data;
- $payload=json_encode(array(
- 'id' => 'rpc',
- 'method' => 'sendwithdata',
- 'params' =>[$address, 0, $data],
- ));
- // echo '<PRE>'; print_r($payload); echo '</PRE>';
- $user = 'digichain';
- $password = "password";
- $ch=curl_init($url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: '.strlen($payload)
- ));
- $response=curl_exec($ch);
- // echo '<PRE>'; print_r($response); echo '</PRE>';
- $result=json_decode($response, true);
- $final_result = $result['result'];
- }
- ?>
Add Comment
Please, Sign In to add comment