<?php
include(__DIR__.'/../includes/sysinit.php');
    
function getAddressOptions($data) {
 
  echo $_POST['field_value'];
  $postCode = $_POST['field_value'];
    echo  $postCode;

  $url = "https://api.ideal-postcodes.co.uk/v1/postcodes/" . "MK44AP" . "?api_key" . IDEAL_POSTAL_API_KEY;
    echo  $url;

  $curl = curl_init();

  curl_setopt_array( $curl, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => array(
      'Accept: application/json'
    ),
  ) );

  $httpCode = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); // this results 0 every time
    
    

  $response = curl_exec( $curl );
  $data = json_decode( $response, true );
  curl_close( $curl );
  echo $response; 
    


        
/*    	$html	= "";
			
			
		$rows = $sableDB->getRows($sql);
		foreach($rows as $row) 
		{
			$html .= '<option value="'.$row['VAL'].'">'.$row['DESCR'].'</option>';
		}
	
	$data['output_list'] = $html;
	SableSystem::ajaxFillField($html, $_POST['field_id']);*/
}

