fork download
  1. <?php
  2. $host = '54.85.96.159';
  3. $port = 5001;
  4. $data = [
  5. "email" => "dilipkumar.gupta@reseit.in",
  6. "cost" => 5
  7. ];
  8.  
  9. $jsonData = json_encode($data);
  10. $fp = fsockopen($host, $port, $errno, $errstr, 30);
  11.  
  12. if (!$fp) {
  13. echo "Error: $errno - $errstr<br />\n";
  14. } else {
  15. $out = "POST /tokens/allocation HTTP/1.1\r\n";
  16. $out .= "Host: $host\r\n";
  17. $out .= "Content-Type: application/json\r\n";
  18. $out .= "Content-Length: " . strlen($jsonData) . "\r\n";
  19. $out .= "Connection: Close\r\n\r\n";
  20. $out .= $jsonData;
  21.  
  22. fwrite($fp, $out);
  23. $response = '';
  24.  
  25. while (!feof($fp)) {
  26. $response .= fgets($fp, 128);
  27. }
  28.  
  29. fclose($fp);
  30.  
  31. echo "Response: $response";
  32. }
  33. ?>
Success #stdin #stdout #stderr 0.02s 26024KB
stdin
Standard input is empty
stdout
Error: 101 - Network is unreachable<br />
stderr
PHP Warning:  fsockopen(): unable to connect to 54.85.96.159:5001 (Network is unreachable) in /home/dKYdYI/prog.php on line 10