Skip to content
English
  • There are no suggestions because the search field is empty.

PHP Example

The Fitnet Leave API is accessible from any environment that supports HTTP.

Here is an example of creating leave from a PHP page.

First you must enable or install the extension cURL and php-json:

  • cURL to make GET and POST requests from PHP.
  • php-json to format the data in JSON format.

<?php
$leave = array("tenantId" => "Fitnet_Apps_DEMO",

"LeaveId" => 1,
"e-mail" => "employee@fitnetapplication.com"
"designation" => "leave"
"TypesAbsences" => array (array ("StartDate" => "22/08/2012", "EndDate" => "31/08/2012", "startMidi" => 0, "endMidi" => 1 "typeId"=> 1)));

$JsonLeave = json_encode ($leave);
$POSTVARS = '{"leave":' $jsonLeave.'}';
$url="http://demo.fitnetmanager.com/FitnetManager/seam/resource/rest/leaveApi/createLeave";
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8", "Accept: application/json, text/javascript, */*; q=0.01"));

curl_setopt($ ch, CURLOPT_POST      ,1);
curl_setopt ($ch, CURLOPT_POSTFIELDS    ,$POSTVARS);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_HEADER      ,0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER  ,1);  
$Rec_Data = curl_exec($ch);
 
echo $Rec_Data;

curl_close($ch);
?>