Skip to content

Instantly share code, notes, and snippets.

@beta-decay
Last active August 4, 2016 18:02
Show Gist options
  • Save beta-decay/3c676c3961f63d31bf2be7fde3dd381e to your computer and use it in GitHub Desktop.
Save beta-decay/3c676c3961f63d31bf2be7fde3dd381e to your computer and use it in GitHub Desktop.
PHP script which gets data from Voyager
<?php
$url = 'http://voyager.gsfc.nasa.gov/cgi-bin/heliopause_all';
$parameters_str = '';
$parameters = array(
'average'=>'6hour',
'syear'=>'9999',
'smonth'=>'9999',
'sday'=>'9999',
'eyear'=>'9999',
'emonth'=>'9999',
'eday'=>'9999',
'sat'=>'1',
'mnemonic'=>'IPGH',
'duration'=>'3-months',
'outputType'=>'list',
'timeFormat'=>'ISO'
);
foreach ($parameters as $k => $v) {
$parameters_str .= $k . '=' . $v . '&';
}
rtrim($parameters_str, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, count($parameters));
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters_str);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
curl_close($ch);
echo $result;?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment