1. Purpose
- Retrieves a human-readable description of the service using PHP to communicate with Labeeb IoT web services. This also verifies that the service exists, without interacting with the resources that it provides.
2. Preparation
- Find in the attachments a file named (labeebIoT.php) that contains all functions needed to communicate with Labeeb IoT platform.
- First, download (labeebIot.rar), and copy it to php folder:

- Inside your php page, include (labeebIoT.php) using require statement :
Include labeebiot.php class
<?php
require "labeebIoT.php";
$labeebWS = new LabeebIot; // Create new object
?>
- Then you can use php functions to call Labeeb IoT web services through ( labeebWS ) object. .
3. PHP functions to interface with Labeeb IoT Web Services:
3.1. User Services:
3.1.1. Authenticate :
Function call : | authenticate(Enterprise:String,userName:string,password:String,IP:String); |
Params | - Enterprise:String : Labeeb IoT platform Enterprise name. required
- userName:String : Labeeb IoT platform user name. required - paaword:String : Labeeb IoT platform password. Required - IP:String : User IP optional
|
Return value | - String : "success" authenticated successfully
- String : "error"+ [ Http header with error message] : authentication fail
|
Sample call | $labeebWS ->authenticate('company','user_1','123@123'); |
Success Response Sample | " success" |
Error Response sample | - "error header :HTTP/1.1 500 Internal Server Error"
|
3.1.2. Logout :
Function call : | logout(); |
Params | |
Return value | - String : "success" logout successfully
- String : "error"+ [ Http header with error message] : logout fail
- String : "error : not logged in" user not logged in
|
Sample call | $labeebWS ->logout(); |
Success Response Sample | " success" |
Error Response sample | - "error header :HTTP/1.1 500 Internal Server Error"
- "error : not logged in"
|
3.2. Data Services
3.2.1. Get Dashboard Data :
Function call : | getDashBoardData(Filters:Array) |
Params | - Filters:Array : Dash Board Data filter options optional
array ( "startDate"=> "dd-mm-yyyy hh:mm:ss.SSS", "endDate" => "dd-mm-yyyy hh:mm:ss.SSS",, "type" => array("Type", "Type", "Type") ) ; Type:list:
- ALL
- DEVICE_STATUS_COUNT
- DEVICE_STATUS_ALERTS_COUNT
- DEVICE_STATUS_LOCATION
- USERS_COUNT
- DEVICES_COUNT
- DATA_RECORDS_COUNT
|
Return value | - JSON object : getDashBoardData successfully
- String : "error"+ [ Http header with error message] : getDashBoardData fail
- String : "error : not logged in" user not logged in
|
Sample call | $options_array = array( "startDate"=> "01-01-2016 00:00:00.000", "endDate" => "10-03-2016 00:00:00.000", "type" => array("DEVICE_STATUS_COUNT", "DEVICE_STATUS_ALERTS_COUNT", "DATA_RECORDS_COUNT") ) ; $labeebWS -->getDashBoardData($options_array); |
Success Response Sample | Array ( [devicesCount] => [storedDataRecordsCount] => 0 [filteredDataRecords] => 0 [behaviorAlertCount] => Array ( [availabilitycount] => Array ( [deviceOfflineCount] => 2 [deviceOnlineCount] => 0 [unknownCount] => 0 ) [statusCount] => Array ( [blacklistedCount] => 0 [malfunctioningCount] => 0 [unknownCount] => 2 [workingCount] => 0 ) [totalAlerts] => 0 [unseenAlerts] => 0 ) ) |
Error Response sample | - "error header :HTTP/1.1 500 Internal Server Error"
- "error : not logged in"
|
3.2.2. Get Activity Logs
Function call : | getActivityLogs (startDate:String, endDate:String,sourceModuleEnum:String,severityEnum:String) |
Params | - startDate:String : format : "yyy-mmdd"."T"."hhmmss+hh:mm" Required
- endDate:String : format : "yyy-mmdd"."T"."hhmmss+hh:mm" Required
- sourceModuleEnum:String : must be "MDD" Required
- severityEnum:String Required severityEnum could be :
EMERGENCY ALERT CRITICAL ERROR WARNING NOTICE INFORMATIONAL DEBUG
|
Return value | - JSON object : getActivityLogs successfully
- String : "error"+ [ Http header with error message] : getActivityLogs fail
- String : "error : not logged in" user not logged in
|
Sample call | $labeebWS -->getActivityLogs("2016-03-01T12:00:00+01:00", "2016-03-15T12:00:00+01:00", "MDD", "NOTICE"); |
Success Response Sample | [0] => Array ( [alerts] => Array ( [0] => Array ( [alertDetail] => [alertId] => 31025 [alertMessage] => OLD Status : WORKING NEW status UNKNOWN [alertSeverity] => NOTICE [alertSourceType] => DEVICE_BEHAVIOR_MONITOR [alertTime] => 2016-03-02T16:57:32.776+03:00 [availability] => [dataModelId] => system [dataTypeId] => mem_used [deviceId] => device1 [deviceTemplateId] => linux [enterpriseId] => qmic_intern [seen] => [status] => UNKNOWN ) ) ) |
Error Response sample | "error header :HTTP/1.1 500 Internal Server Error" |
3.2.3. get Data
Function call : | getData (maxDataRecords:String, DataSearchCriteria:Array) |
Params | - maxDataRecords:String : max number of records to retrieve Required
- DataSearchCriteria:Array Required
array(" dataModelName"=> "YOUR_DATA_NAME_MODEL" ,"dataTypeName" => " YOUR_DATA_TYPY_NAME" ,"deviceName" => "YOUR_DEVICE_NAME", "fromDate" => "yyyy-mm-ddThh:mm:ss+hh:mm", "operatorEnum" => "FROM_LIST_DOWN", "thresholdValue" => "YOUR_THRESHHOLD_VALUE" "toDate" => "yyyy-mm-ddThh:mm:ss+hh:mm" ); "operatorEnum" could be : CONTAINS EQUAL DIFFERENT GREATER_THAN GREATER_OR_EQUAL_TO LESS_OR_EQUAL_TO LESS_THAN
|
Return value | - JSON object : getData successfully
- String : "error"+ [ Http header with error message] : getData fail
- String : "error : not logged in" user not logged in
|
Sample call | $DataSearchCriteria=array("dataModelName"=> "Battery", "dataTypeName" => "battery", "deviceName" => "Device_1", "fromDate" => "2015-12-14T12:00:00+03:00", "operatorEnum" => "GREATER_THAN", "thresholdValue" => "0", "toDate" => "2016-03-15T12:00:00+03:00"); $labeebWS ->getData ("100",$DataSearchCriteria )); |
Success Response Sample | Array ( [0] => Array ( [altitudeInMeters] => [booleanValue] => [dataModelId] => temp_data [dataSource] => GENERIC_MQTT_M_2_M_DEVICES [dataTime] => 2016-03-27T10:27:00+03:00 [dataTypeId] => temp_value [deviceId] => php_device [doubleValue] => 66 [latitude] => [longitude] => [receiveTime] => 2016-03-27T10:27:01.396+03:00 [storeTime] => 2016-03-27T10:27:01.403+03:00 [stringValue] => ) ) |
Error Response sample | "error header :HTTP/1.1 500 Internal Server Error" |
3.3. Device Services
3.3.1. getDevices
Function call : | getDevices(deviceStatusEnum_list:Array,deviceAvailibiltyEnum_list:Array,deviceName:String) |
Params | - deviceStatusEnum_list:Array : optional*
List : WORKING MALFUNCTIONING BLACKLISTED UNKNOWN - deviceAvailibiltyEnum_list:Array optional*
List : OFFLINE ONLINE UNKNOWN - deviceName:String optional*
|
Return value | - JSON object : getDevices successfully
- String : "error"+ [ Http header with error message] : getDevices fail
- String : "error : not logged in" user not logged in
|
Sample call | $deviceStatusEnum_data = array ("WORKING","BLACKLISTED"); $deviceAvailibiltyEnum_data= array ("OFFLINE","UNKNOWN"); $labeebWS ->getDevices($deviceStatusEnum_data,$deviceAvailibiltyEnum_data,"tempreture_device"); |
Success Response Sample | Array ( [0] => Array ( [deviceStatusEnum] => [deviceAvailibiltyEnum] => OFFLINE [deviceHeartbeatProfile] => Array ( [intelligenceAlgo] => PERIODIC [numberPackets] => 1 [timeMeasure] => SECOND [timePeriod] => 15 ) [deviceName] => php_device [deviceTemplateId] => temp_sensor [deviceTypeEnum] => SENSOR [latestLocation] => Array ( [altitudeInMeters] => 0 [description] => [latitude] => 0 [locationName] => [longitude] => 0 ) ) ) |
Error Response sample | "error header :HTTP/1.1 500 Internal Server Error" |
3.3.2. getLatestDeviceBehavior :
Function call : | getLatestDeviceBehavior (DeviceBehaviorRequest:Array) |
Params | - DeviceBehaviorRequest:Array : required *
array("deviceIds"=> array("DEVICE_1","DEVICE_2"), "statusFilter"=> array("MALFUNCTIONING","WORKING"), "availabilityFilter"=> array("OFFLINE" ) ) ;
|
Return value | - JSON object : getLatestDeviceBehavior successfully
- String : "error"+ [ Http header with error message] : getLatestDeviceBehavior fail
- String : "error : not logged in" user not logged in
|
Sample call | $DeviceBehaviorRequest = array("deviceIds"=> array("temp_1","temp_2"), "statusFilter"=> array("MALFUNCTIONING","WORKING"), "availabilityFilter"=> array("OFFLINE" )) ; $ labeebWS ->getLatestDeviceBehavior ($DeviceBehaviorRequest); |
Success Response Sample | Array ( [0] => Array ( [behaviors] => ) ) |
Error Response sample | "error header :HTTP/1.1 500 Internal Server Error" |
3.3.3. getDeviceNames
Function call : | getDeviceNames() |
Params | |
Return value | - JSON object : getDeviceNames successfully
- String : "error"+ [ Http header with error message] : getDeviceNames fail
- String : "error : not logged in" user not logged in
|
Sample call | $ labeebWS -> getDeviceNames(); |
Success Response Sample | Array ( [0] => city_center_temp_1 [1] => php_device ) |
Error Response sample | "error header :HTTP/1.1 500 Internal Server Error" |
3.3.4. getDataModelNames :
Function call : | getDataModelNames() |
Params | |
Return value | - JSON object : getDataModelNames successfully
- String : "error"+ [ Http header with error message] : getDataModelNames fail
- String : "error : not logged in" user not logged in
|
Sample call | $ labeebWS -> getDataModelNames(); |
Success Response Sample | Array ( [0] => temp_data ) |
Error Response sample | "error header :HTTP/1.1 500 Internal Server Error" |
3.3.5. getDataTypeNames
Function call : | getDataTypeNames(dataModelNames:Array) |
Params | dataModelNames:Array : List of data madel names required |
Return value | - JSON object : getDataModelNames successfully
- String : "error"+ [ Http header with error message] : getDataModelNames fail
- String : "error : not logged in" user not logged in
|
Sample call | $dataModelNames = array ("Magnetometer","Accelerometer"); $ labeebWS -> getDataTypeNames($dataModelNames); |
Success Response Sample | Array ( [0] => temp_data ) Array ( [0] => temp_value ) |
Error Response sample | "error header :HTTP/1.1 500 Internal Server Error" |