Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // A sample PHP Script to POST data using cURL
- // Data in JSON format
- $data = array(
- 'ip' => $_GET['ip'],
- 'port' => $_GET['port'],
- 'topic' => $_GET['topic']
- );
- $payload = json_encode($data);
- // Prepare new cURL resource
- $ch = curl_init('https://listaipro.firebaseio.com/Salas.json');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLINFO_HEADER_OUT, true);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
- // Set HTTP Header for POST request
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen($payload))
- );
- // Submit the POST request
- $result = curl_exec($ch);
- echo $result;
- // Close cURL session handle
- curl_close($ch);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement