Using GET and POST when calling activities with HANO API services in PHP

This example will properly show you how to implement POST and GET calls to Hano API including the required parameters. Well you will have to have a valid API key, as I will comment out mine. But I assure you, this code is working at the time I am writing this article. I didn’t cover all available calls to HANO API, but this is even more than enough to get you going in the right direction. Current code actually retrieves different booking types, available booking times from the HANO service, and in the end using the acquired info, tries to create a customer and then book that customer for specific booking window frame.


These are the configuration and helper function scripts that will help you communicate with HANO API

// Begin configuration for Hano Api 
$configurationFor["apiKey"]='Put your own HANO API Key here!';


$configurationFor["resourceId"]='1'; //from'Put your own HANO API Key here!'; 

function CallAPI( $url, $data=false)
     if ($data) $url = sprintf("%s?%s", $url, http_build_query($data));	 
	 $curl = curl_init($url);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
		//execute the session
		 $curl_response = curl_exec($curl);
		//finish off the session
		return $curl_response;

function httpPost($url,$params)
  $fields_string =http_build_query($params); 
    $ch = curl_init($url); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);  
    //curl_setopt($ch,CURLOPT_HEADER, false); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); 
    return $output; 



1. Get the HANO API Booking Types and put them in drop-down example

//fill Dropdown

	echo '<select class="floatLabel" id="BookingType">';
	echo '<option value="">Chose Type Of Booking</option>';
	foreach ($response as $row) {
	echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
	echo '</select>';

2. Get the HANO API Available Booking Times and put them in option radio button

//get available dates and put them in option box

	$data["serviceId"]=3;  //from //2.3.1 List 
	$data["resourceId"]=$configurationFor["resourceId"]; //depends on HANO database configuration

    //Display time 
         foreach ($response['results'] as $row) {			 
    		echo '<input type="radio" value="'.$row['time'].'" name="time"/>'.substr($row['start'], -8,5).'-'.substr($row['end'], -8,5).'</br>';	}
        echo 'No Booking time available';

3. Create HANO API Customer and then use the customer to book specific time


//add bogus data depending on customer scheme in HANO API Config
$regdata["address1"]='No address';


   // now add the booking to that user
	$data["serviceId"]="3";  //from //2.3.1 List


		//Display book result
		   echo '<h2 class="heading">Booking Success for:</h2>
				<div class="controls">
				  <input type="text" id="name" class="floatLabel" name="name" value="'.$regdata["name"].'">				  
				<div class="controls">
				  <input type="tel" id="surname" class="floatLabel" name="surname" value="'.$regdata["surname"].'">				  
				<div class="controls">
				  <input type="text" id="email" class="floatLabel" name="email" value="'.$regdata["email"].'">				  
				<div class="controls">
				  <input type="text" id="id" class="floatLabel" name="email" value="'.$responseBook["id"].'">				  
				</div>    ';						
			echo '<span>Error Booking! </span>'.print_r($responseBook);
	echo '<span>Error Booking Customer </span>' .print_r($response);


1. Output of Get the HANO API Booking Types and put them in drop-down example

<select class="floatLabel" id="BookingType">
	<option value="">Chose Type Of Booking</option>
	<option value="3">Konsultasjon Ny kunde</option>
	<option value="12">Mikrotatovering</option>
	<option value="8">Liten tatovering </option>
	<option value="9">Medium tatovering</option>
	<option value="11">Large tatovering</option>
	<option value="10">XL - Tatovering</option>
	<option value="13">PMU Bryn</option>
	<option value="14">ikke aktiv kunde</option>
	<option value="15">Sett inn navn her</option>

2. Output of Get the HANO API Available Booking Times and put them in option radio button

<input value="58956" name="time" type="radio">12:00-12:15<br>
<input value="59190" name="time" type="radio">15:15-15:30<br>
<input value="59208" name="time" type="radio">15:30-15:45<br>

3. Output of Create HANO API Customer and then use the customer to book specific time

<h2 class="heading">Booking Success for:</h2>
<div class="controls">
<input id="name" class="floatLabel" name="name" value="John" type="text">
<div class="controls">
<input id="surname" class="floatLabel" name="surname" value="Smith" type="tel">
<div class="controls">
<input id="email" class="floatLabel" name="email" value="" type="text">
<div class="controls">
<input id="id" class="floatLabel" name="email" value="34461" type="text">


What you may be forgetting:

1.Don’t forget to include the API Key in the Hano Service URL when using POST function

2.Check your HANO API Customer Creation required parameters scheme, as some additional parameters may be required in your DB

3.Make sure you use Time ID when scheduling/booking that is not expired (duh… )

4. This example uses loosely the resource ID parameter (I don’t care to whom to book the time) Maybe you will have to additionally change this parameter to your convenience

This example was done with PHP Version 5.6.15  running on Apache/2.4.17 (Win32)

Leave a Reply

Your email address will not be published. Required fields are marked *