Return to Snippet

Revision: 70855
at August 5, 2016 05:04 by BetaDecay


Initial Code
<?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;?>

Initial URL


Initial Description
Gets data from Voyager probe

Initial Title
NASA Voyager php data getter

Initial Tags


Initial Language
PHP