Moved local to live server, now Simbrief API not loading output page

So, we have moved from a localhost development to a live server for further developments. Prior to moving to a live server, simbrief API works flawlessly, generates OFP, and it outputs the page with the simbrief data.

However, now moving to a live server, we fill out the details for simbrief, departure, arrival, aircraft type, and any other details. We clicked on the generate button, and the pop-up window for Simbrief showed. It successfully generated the flight plan, and the pop-up closed. However, the page didn’t get reloaded as it should have reloaded with the Simbrief OFP ID encoded in the URL, but it never did.

Taking a look at the debugger after the Simbrief pop up closes, (URL has been redacted), this is what I got in my debugger for the URL

https://*********/pages/flights/simbrief.apiv1.php?js_url_check=1705463773_9EEA465C66&var=fe_result&p=9987971

And the response was

var fe_result = “false”;

The PHP file and the JS is in the same directory.

Any advice on what I should look into and how to correct this?

Thanks!

Kyle

Hi Kyle, check your PHP configuration on your live server and see if allow_url_fopen is enabled. The API sample files need that setting in order to work.

If you cannot (or would rather not) enable that setting, you can use the following alternative PHP code which uses cURL instead.

Simply add the following function somewhere in simbrief.apiv1.php:

function get_headers_curl($url) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_NOBODY, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_HEADER, true);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,5);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10);
	
	$header = curl_exec($ch);
	curl_close($ch);
	
	return preg_split('/[\r\n]+/', strval($header));
	}

Then, change line 53 from:

$fh = get_headers($url);

To:

$fh = get_headers_curl($url);

Best regards,

That was the issue, allow_url_fopen was disabled on the server. I enabled this, and everything is working seamlessly!

Thanks for your speedy response!

Cheers!

Kyle

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.