Dispatching to Simbrief

Once I created, I am going to fetch the ofp. Directing to create but getting “Fatal Exception:Missing Parameters!” error.

I am not even sure if I can express my problem correctly with “coder” words :slight_smile:

<!-- Dispatch to SimBrief -->
<script>
    function dispatchToSimBrief() {
        let userid = "{{ user.simbrief_id }}";
        let static_id = "{{ user.static_id }}";
        let origin = "{{ departure_airport.icao }}";
        let destination = "{{ arrival_airport.icao }}";
        let type = "{{ selected_aircraft.internal_id }}";  
        let fltnum = "{{ flight_number }}";
        let callsign = "{{ callsign }}";
        let api_key = MY_API_KEY;  
        let units = "KGS";
        let airline = "INK"; 
    
        console.log("DEBUG: Checking Parameters Before Dispatch");
        console.log("UserID:", userid);
        console.log("Static ID:", static_id);
        console.log("Origin:", origin);
        console.log("Destination:", destination);
        console.log("Type (Internal ID):", type);
        console.log("Flight Number:", fltnum);
        console.log("Callsign:", callsign);
        console.log("API Key:", api_key);
        console.log("Airline:", airline);
    
        if (!userid || !static_id || !origin || !destination || !type || !fltnum || !callsign) {
            alert("Error: Missing required parameters. Please check your flight details.");
            return;
        }
        let simbriefURL = `https://www.simbrief.com/ofp/ofp.loader.api.php?airline=${airline}&userid=${userid}&static_id=${static_id}&orig=${origin}&dest=${destination}&type=${type}&fltnum=${fltnum}&callsign=${callsign}&units=KGS`;
    
        console.log("SimBrief Dispatch URL:", simbriefURL);
        window.open(simbriefURL, "_blank");  
    }
    </script>
    <div class="center-align" style="margin-top: 20px;">
        <button class="btn orange darken-2" onclick="dispatchToSimBrief();">
            Dispatch to SimBrief
        </button>
    </div>
    <!-- Dispatch to SimBrief Ended -->

Checked on console and URL, they are all correct. But not sure all are necessary. Actualy my concerns are: orig, dest, type, fltnum,callsign

Above codes may be nonsense, but this is how 50yrs old noob coding guy asks :slight_smile:
Thanks for your help in advance.

Hi, you will need to pass the following additional parameters to the SimBrief URL:

timestamp = { current_unix_time }
outputpage = { redirect_url }
apicode = md5( { api_key } + { origin } + { destination } + { type } + { timestamp } + { outputpage } )

To clarify, the outputpage should be the URL on your website that you will view the resulting SimBrief flight plan. For example https://www.example.com/view_simbrief.php.

timestamp should be equal to the current Unix time.

apicode is an md5 hash of a concatenated string as described above. This hashes your API key so that it can be verified without having to send the actual key in the URL.

Best regards,

It was like you touched it with your magic wand. I’ve been trying to figure this out for days, and I started to think it was because of Django. Thank you very much indeed. :slight_smile: