Advertisement
dahnnyel1

Untitled

Jul 18th, 2020
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2. // A sample PHP Script to POST data using cURL
  3. // Data in JSON format
  4.  
  5. $data = array(
  6. 'ip' => $_GET['ip'],
  7. 'port' => $_GET['port'],
  8. 'topic' => $_GET['topic']
  9. );
  10.  
  11. $payload = json_encode($data);
  12.  
  13. // Prepare new cURL resource
  14. $ch = curl_init('https://listaipro.firebaseio.com/Salas.json');
  15. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  16. curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  17. curl_setopt($ch, CURLOPT_POST, true);
  18. curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
  19.  
  20. // Set HTTP Header for POST request
  21. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  22. 'Content-Type: application/json',
  23. 'Content-Length: ' . strlen($payload))
  24. );
  25.  
  26. // Submit the POST request
  27. $result = curl_exec($ch);
  28.  
  29. echo $result;
  30.  
  31. // Close cURL session handle
  32. curl_close($ch);
  33.  
  34.  
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement