NASA/JPL Horizons Batch to PHP Code Conversion Tool
A PHP Tool For Use With the NASA/JPL Horizons API
Program by Jay Tanner of Geneva, NY, USA - 2026
Double-Click Within Text Area to Select ALL Batch Text
Double-Click Within Text Area to Select ALL PHP Code
Paste any valid ephemeris batch-file text produced by the Horizons app in the light cyan text area above and then click the [SUBMIT] button. The generated PHP code will be displayed in this text area and can be edited and customized. The first line at the top of all Horizons batch files must be the marker: !$$SOF Followed by the list of Horizons ephemeris API control parameters. NOTE: Some PHP code errors may not be detected until run-time.
Double-Click Within Text Area to Select ALL Text
To make use of this PHP tool requires the user to have a PHP-enabled public or private web site or home web server with an Internet connection to access the NASA/JPL Horizons API remotely. This program assumes that the user is at least minimally familiar with PHP and the NASA/JPL Horizons web interface and knows how to use the interface to generate a basic ephemeris. All of the same Horizons rules apply here. ================================================================== EXAMPLE: Using the initial default Horizons interface app settings. This example demonstrates how to create your own custom NASA/JPL Horizons ephemeris functions using PHP (v8.2+). Most of the code is generic, so it should run on most versions of PHP after v5. It's really rather simple. ================================================================== STEP 1: In a new browser tab: Go to the NASA/JPL Horizons public web app at: https://ssd.jpl.nasa.gov/horizons/app.html Simply use whatever default settings are already set up there for this example. Nothing needs to be changed. You will see a green button at the bottom of the interface that says [Generate Ephemeris]. Ignore that button for now. Above that green button is a statement offering to provide a batch file corresponding to the settings. Simply click on 'this link' at the end of the statement and then the requested batch-file text will be generated below the green button. This is the batch text we need to begin the demo work. ====================================================================== STEP 2: Copy the entire block of the returned 'Batch Data File' text and paste it into the light cyan input text area above. The batch text file always begins with the header line: !$$SOF followed by a list of Horizons API ephemeris control parameters. Then click the [SUBMIT] button to generate the PHP source code required to generate the ephemeris thereafter. Running the generated source code should produce the same ephemeris. The code can then be modified and adapted for custom application. ====================================================================== This program makes it easy to construct your own PHP software to compute customized ephemerides based on the NASA/JPL Horizons API. You make all the settings necessary to generate your ephemeris and then generate the batch-file text. The batch-file text will be used to generate independent PHP source code to perform all of the same operations needed to generate the ephemeris. The code can then be used as a template around which to develop a customized astronomy program in PHP. This tool is designed to save software development time. The functions generated should be ready to run in demo mode and you can take it from there and develop a customized program around it. ====================================================================== If you want to find the date when Voyager 1 will reach a distance of one light day (1440 light minutes) from Earth, use the following batch file text to generate the PHP function code for a daily ephemeris just for that purpose. See dates: 2026-Nov-19 / 2026-Nov-20 This ephemeris is geocentric UTC. !$$SOF MAKE_EPHEM='YES' EPHEM_TYPE='OBSERVER' CENTER='500@399' COMMAND='-31' OBJ_DATA='NO' START_TIME='2026-Nov-01' STOP_TIME='2026-Dec-01' STEP_SIZE='1 DAY' SUPPRESS_RANGE_RATE='YES' CSV_FORMAT='YES' QUANTITIES='20,21' ----------------------------------------------------------------------- If you want to find the date when Voyager 2 will reach a distance of one light day (1440 light minutes) from Earth, use the following batch file text to generate the PHP function code for a daily ephemeris just for that purpose. See dates: 2035-Nov-01 / 2035-Nov-02 This ephemeris is geocentric UTC. !$$SOF MAKE_EPHEM='YES' EPHEM_TYPE='OBSERVER' CENTER='500@399' COMMAND='-32' OBJ_DATA='NO' START_TIME='2035-Nov-01' STOP_TIME='2035-Dec-01' STEP_SIZE='1 DAY' SUPPRESS_RANGE_RATE='YES' CSV_FORMAT='YES' QUANTITIES='20,21' ====================================================================== CAVEAT The executable PHP will fail if there are any erroneous batch data entries, but this will not be detected until run-time. ====================================================================== Hint: By changing the COMMAND to another ID number, the same derived script can be used for that object instead. The ID# is the number of the object in the NASA/JPL Horizons database. 10 = Sun 199 = Mercury 299 = Venus 399 = Earth 301 = Moon ... 499 = Mars ... 999 = Pluto ======================================================================
Program by Jay Tanner of Geneva, NY, USA - 2026
v1.10 - Revised: 1970-January-01-Thursday at Local Time 00:00:00 (UTC)