Php curl

Can you use PHP curl to get the api results as I already can get some information I need from Genames using the PHP Curl method .

if it is possible is it just a case of creating a url string with the parameters like &api_key= etc.
for example I use this like I said for

//	curl -X GET "" \
//	-H "Accept: application/json; charset=UTF-8" 
	echo 'Process 01 - Getting Geonames Data ' . "<br>";
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$headers = [
		'X GET ""',
		'Accept: application/json; charset=UTF-8', 
		'x-apikey: api key hidden for this example'
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	$server_output = curl_exec ($ch);
	curl_close ($ch);
	$aedata= json_decode($server_output, true);

when I ran this the var_dump returned NULL. no Curl errors reported ?

after some trial and error and using the documentation TRY IT and looking at the CURL schema I finally got it to work

$url = "";

$curl = curl_init($url);

curl_setopt($curl, CURLOPT_URL, $url);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, **true**);

$headers = array(

"Accept: application/json; charset=UTF-8",

"x-apikey: hidden for this message purposes",


curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

//for debug only!

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, **false**);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, **false**);

$resp = curl_exec($curl);



to which I got the data

string(405) "{"airport_code":"EGKK","alternate_ident":"LGW","code_icao":"EGKK","code_iata":"LGW","code_lid":null,"name":"London Gatwick","type":"Airport","elevation":196,"city":"London","state":"England","longitude":-0.190278,"latitude":51.148056,"timezone":"Europe/London","country_code":"GB","wiki_url":"","airport_flights_url":"/airports/EGKK/flights","alternatives":[]}"