NASA Voyager php data getter


/ Published in: PHP
Save to your folder(s)

Gets data from Voyager probe


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. $url = 'http://voyager.gsfc.nasa.gov/cgi-bin/heliopause_all';
  4. $parameters_str = '';
  5. $parameters = array(
  6. 'average'=>'6hour',
  7. 'syear'=>'9999',
  8. 'smonth'=>'9999',
  9. 'sday'=>'9999',
  10. 'eyear'=>'9999',
  11. 'emonth'=>'9999',
  12. 'eday'=>'9999',
  13. 'sat'=>'1',
  14. 'mnemonic'=>'IPGH',
  15. 'duration'=>'3-months',
  16. 'outputType'=>'list',
  17. 'timeFormat'=>'ISO'
  18. );
  19.  
  20. foreach ($parameters as $k => $v) {
  21. $parameters_str .= $k . '=' . $v . '&';
  22. }
  23. rtrim($parameters_str, '&');
  24.  
  25.  
  26. $ch = curl_init();
  27.  
  28. curl_setopt($ch, CURLOPT_URL, $url);
  29. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  30. curl_setopt($ch, CURLOPT_POST, count($parameters));
  31. curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters_str);
  32. curl_setopt($ch, CURLOPT_HEADER, false);
  33.  
  34.  
  35. $result = curl_exec($ch);
  36.  
  37.  
  38. echo $result;?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.