The PHP Client library is used to communicate with Cloudplugs platform with HTTP REST requests to the server. More...
Public Member Functions | |
__construct ($options=NULL) | |
__destruct () | |
setOptions ($optionsArray) | |
enableSSL ($enabled) | |
hasSSL () | |
setAuthId ($id) | |
setDebugMode ($enabled) | |
setOutputFormat ($format) | |
getLastHttpResultCode () | |
getLastHttpResultString () | |
getLastErrorString () | |
getLastErrorCode () | |
setBaseUrl ($url) | |
getBaseUrl () | |
setTimeout ($seconds) | |
getTimeout () | |
setCACert ($certPath=NULL) | |
setAuth ($id, $pass, $is_master=FALSE) | |
getAuthId () | |
getAuthPass () | |
isAuthMaster () | |
getServerResponse () | |
enrollProductEx ($model, $hwid, $pass, $props=NULL, $propLinks=NULL) | |
enrollProduct ($data, $outputFormat=NULL) | |
enrollPrototypeEx ($name, $pass=NULL, $hwid=NULL, $perm=NULL, $props=NULL, $propLinks=NULL) | |
enrollPrototype ($data=NULL, $outputFormat=NULL) | |
getDevice ($plugid=NULL, $outputFormat=NULL) | |
setDeviceLocationEx ($plugid, $longitude, $latitude, $altitude, $accuracy, $timestamp) | |
setDeviceLocation ($data, $outputFormat=NULL) | |
getDeviceLocationEx ($plugid=NULL) | |
getDeviceLocation ($data=NULL, $outputFormat=NULL) | |
setDeviceProp ($plugid=NULL, $prop=NULL, $value, $outputFormat=NULL) | |
removeDeviceProp ($plugid, $prop, $outputFormat=NULL) | |
getDeviceProp ($plugid=NULL, $prop=NULL, $outputFormat=NULL) | |
publishData ($data, $channel=NULL, $outputFormat=NULL) | |
removeDataEx ($channelMask, $id=NULL, $before=NULL, $after=NULL, $at=NULL, $of=NULL) | |
removeData ($data, $outputFormat=NULL) | |
retrieveDataEx ($channelMask, $before=NULL, $after=NULL, $at=NULL, $of=NULL, $offset=NULL, $limit=NULL) | |
retrieveData ($data, $outputFormat=NULL) | |
listChannelsEx ($channelMask, $before=NULL, $after=NULL, $at=NULL, $of=NULL, $offset=NULL, $limit=NULL) | |
listChannels ($data, $outputFormat=NULL) | |
unenroll ($data=NULL, $outputFormat=NULL) | |
setDeviceEx ($id=NULL, $perm=NULL, $name=NULL, $status=NULL, $props=NULL, $propLinks=NULL) | |
setDevice ($data=NULL, $outputFormat=NULL) | |
enrollControllerEx ($model, $ctrl, $pass, $hwid, $name) | |
enrollController ($data=NULL, $outputFormat=NULL) | |
uncontrolDevice ($plugid=NULL, $plugidControlled=NULL, $outputFormat=NULL) | |
controlDeviceEx ($model, $ctrl, $pass, $hwid=NULL, $name=NULL) | |
controlDevice ($data, $outputFormat=NULL) | |
Public Attributes | |
const | TIMEOUT = 60 |
const | BASEURL = "https://api.cloudplugs.com/iot/" |
const | HTTP_STR = "http://" |
const | HTTPS_STR = "https://" |
const | PLUG_AUTH_HEADER = "X-Plug-Auth: " |
const | PLUG_ID_HEADER = "X-Plug-Id: " |
const | PLUG_EMAIL_HEADER = "X-Plug-Email: " |
const | PLUG_MASTER_HEADER = "X-Plug-Master: " |
const | CONTENT_TYPE_JSON = "Content-type: application/json" |
const | PATH_DATA = "data" |
const | PATH_DEVICE = "device" |
const | PATH_CHANNEL = "channel" |
const | CTRL = "ctrl" |
const | HWID = "hwid" |
const | NAME = "name" |
const | MODEL = "model" |
const | PASS = "pass" |
const | PERM = "perm" |
const | PROPS = "props" |
const | STATUS = "status" |
const | PROP_LINKS = "prop_links" |
const | DATA = "data" |
const | BEFORE = "before" |
const | AFTER = "after" |
const | OF = "of" |
const | OFFSET = "offset" |
const | LIMIT = "limit" |
const | AUTH = "auth" |
const | ID = "id" |
const | AT = "at" |
const | CHMASK = "channel_mask" |
const | LOCATION = "location" |
const | LONGITUDE = "x" |
const | LATITUDE = "y" |
const | ACCURACY = "r" |
const | ALTITUDE = "z" |
const | TIMESTAMP = "t" |
const | MAX_LONGITUDE = 180.0 |
const | MIN_LONGITUDE = -180.0 |
const | MAX_LATITUDE = 90.0 |
const | MIN_LATITUDE = -90.0 |
const | TYPE_CTRL = 1 |
const | TYPE_HWID = 2 |
const | TYPE_NAME = 3 |
const | TYPE_MODEL = 4 |
const | TYPE_PASS = 5 |
const | TYPE_PERM = 6 |
const | TYPE_PROPS = 7 |
const | TYPE_STATUS = 8 |
const | TYPE_PROP_LINKS = 9 |
const | TYPE_DATA = 10 |
const | TYPE_BEFORE = 11 |
const | TYPE_AFTER = 12 |
const | TYPE_OF = 13 |
const | TYPE_OFFSET = 14 |
const | TYPE_LIMIT = 15 |
const | TYPE_AUTH = 16 |
const | TYPE_ID = 17 |
const | TYPE_OID = 18 |
const | TYPE_AT = 19 |
const | TYPE_CHMASK = 20 |
const | TYPE_LOCATION = 21 |
const | TYPE_LONGITUDE = 22 |
const | TYPE_LATITUDE = 23 |
const | TYPE_ACCURACY = 24 |
const | TYPE_ALTITUDE = 25 |
const | TYPE_TIMESTAMP = 26 |
const | TYPE_PLUG_ID = 27 |
const | TYPE_PLUG_ID_ARR = 28 |
const | TYPE_PLUG_ID_CSV = 29 |
const | TYPE_TIMESTAMP_ARR = 30 |
const | TYPE_TIMESTAMP_CSV = 31 |
const | TYPE_OID_ARR = 32 |
const | TYPE_OID_CSV = 33 |
const | FORMAT_JSON = 0 |
const | FORMAT_ARRAY = 1 |
const | FORMAT_OBJECT = 2 |
const | HTTP_GET = 0 |
const | HTTP_POST = 1 |
const | HTTP_PUT = 2 |
const | HTTP_DELETE = 3 |
const | HTTP_PATCH = 4 |
const | ERR_INTERNAL = -1 |
const | ERR_OUT_OF_MEMORY = -2 |
const | ERR_INVALID_SESSION = -3 |
const | ERR_QUERY_IS_NOT_OBJECT = -4 |
const | ERR_QUERY_INVALID_TYPE = -5 |
const | ERR_HEADER_MUST_BE_STRING = -6 |
const | ERR_INVALID_PARAMETER = -7 |
const | ERR_INVALID_LOGIN = -8 |
const | ERR_JSON_PARSE = -9 |
const | ERR_JSON_ENCODE = -10 |
const | ERR_INVALID_CONTENT_LENGTH = -11 |
const | ERR_HTTP = -12 |
const | ERR_NETWORK = -13 |
const | HTTP_RES_OK = 200 |
const | HTTP_RES_CREATED = 201 |
const | HTTP_RES_MULTISTATUS = 207 |
const | HTTP_RES_BAD_REQUEST = 400 |
const | HTTP_RES_UNAUTHORIZED = 401 |
const | HTTP_RES_PAYMENT_REQUIRED = 402 |
const | HTTP_RES_FORBIDDEN = 403 |
const | HTTP_RES_NOT_FOUND = 404 |
const | HTTP_RES_NOT_ALLOWED =405 |
const | HTTP_RES_NOT_ACCEPTABLE = 406 |
const | HTTP_RES_SERVER_ERROR = 500 |
const | HTTP_RES_NOT_IMPLEMENTED = 501 |
const | HTTP_RES_BAD_GATEWAY = 502 |
const | HTTP_RES_SERVICE_UNAVAILABLE = 503 |
Static Public Attributes | |
static | $HTTP_METHODS = array ( "GET", "POST", "PUT", "DELETE", "PATCH" ) |
The PHP Client library is used to communicate with Cloudplugs platform with HTTP REST requests to the server.
This class contains basically two sets of methods: a set of configuration functions used to configure the class's parameters, and a set of functions used to perform HTTP requests to Cloudplugs server. A set of configuration options are available: for example it is possible to force the library to return server response in a specific output (json, array, object) or run the library in debug mode (display debugging information). All HTTP requests to the server are synchronous. Many functions are provided in two different forms: an explicit parameters version and a compact parameter version (passed within an array or a JSON encoded string).
__construct | ( | $options = NULL | ) |
array | $options | (optional) an associative array (option => value). Supported options: "outputFormat" => "json" or "array" or "object" (forces following requests output to be returned in that format) "debugMode" => TRUE or FALSE (show/hide debug information) "timeout" => int (max number of milliseconds to wait for server response) "id" => String (set the authentication ID to use) "pass" => String (set the authentication password to use) "isMaster" => TRUE or FALSE (if authentication refers to a master password) "baseUrl" => String (the base URL to be used to perform remote HTTP requests) "enableSSL" => TRUE or FALSE (whether to enable SSL or not) |
__destruct | ( | ) |
controlDevice | ( | $data, | |
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to obtain the privileges to control a device (read or publish data for that device) (compact parameters version)
array | string | $data | array or JSON string containing the following parameters: "model" => PLUG_ID model id of the device to control "ctrl" => HWID serial number of the device to control "pass" => password value "hwid" => (optional) HWID unique string to identify this controller device "name" => (optional) the name of this device |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
controlDeviceEx | ( | $model, | |
$ctrl, | |||
$pass, | |||
$hwid = NULL , |
|||
$name = NULL |
|||
) |
This function performs an HTTP request to the server to obtain the privileges to control a device (read or publish data for that device) (explicit parameters version)
string | $model | PLUG_ID model id of the device to control |
string | $ctrl | HWID serial number of the device to control |
string | $pass | password value |
string | $hwid | (optional) HWID unique string to identify this controller device |
string | $name | (optional) the name of this device |
enableSSL | ( | $enabled | ) |
Sets SSL on/off.
bool | $enabled | SSL operating mode value. |
enrollController | ( | $data = NULL , |
|
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to enroll a controller device. This function can be invoked only if no ID set or if id is an Xplug email. After request, authentication credentials are automatically set to controller (compact parameters version)
array | string | $data | array or JSON string containing the following parameters: "model" => PLUG_ID model id of the device to control "ctrl" => HWID serial number of the device to control "pass" => password value "hwid" => HWID unique string to identify this controller device "name" => the name of this device |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
enrollControllerEx | ( | $model, | |
$ctrl, | |||
$pass, | |||
$hwid, | |||
$name | |||
) |
This function performs an HTTP request to the server to enroll a controller device. This function can be invoked only if no ID set or if id is an Xplug email. After request, authentication credentials are automatically set to controller (explicit parameters version)
string | $model | PLUG_ID model id of the device to control |
string | $ctrl | HWID serial number of the device to control |
string | $pass | password value |
string | $hwid | HWID unique string to identify this controller device |
string | $name | the name of this device |
enrollProduct | ( | $data, | |
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to enroll a new production device (compact parameters version). After request auth credentials are authomatically set to enrolled device.
array | string | $data | array or json encoded string containing the following parameters: "model" => PLUG_ID "hwid" => HWID "pass" => String "props" => array, optional, to initializa custom properties "prop_links" => PROP_LINKS optional, to inizialize the properties links (not supported yet, present only for future use) |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
enrollProductEx | ( | $model, | |
$hwid, | |||
$pass, | |||
$props = NULL , |
|||
$propLinks = NULL |
|||
) |
This function performs an HTTP request to the server to enroll a new production device (explicit parameters version). After request auth credentials are automatically set to enrolled device.
string | $model | PLUG_ID the model of this device |
string | $hwid | HWID the serial number |
string | $pass | password value |
array | $props | (optional), to initialize the custom properties |
array | object | $propLinks | (optional) PROP_LINKS to inizialize the properties links (not supported yet, present only for future use) |
enrollPrototype | ( | $data = NULL , |
|
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to creates a new (prototype) device (X-Plug-Master header required. Compact parameters version)
array | string | $data | array or json encoded string containing the following parameters: "name" => String "pass" => String (optional) if absent set as the X-Plug-Master of the company "hwid" => HWID (optional) if absent it will be set as a random unique string "perm" => PERM_FILTER (optional) if absent permit all "props" => array, optional, to initializa custom properties "props_links" => PROP_LINKS optional, to inizialize the properties links (not supported yet, present only for future use) |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
enrollPrototypeEx | ( | $name, | |
$pass = NULL , |
|||
$hwid = NULL , |
|||
$perm = NULL , |
|||
$props = NULL , |
|||
$propLinks = NULL |
|||
) |
This function performs an HTTP request to the server to create a new (prototype) device (X-Plug-Master header required) (explicit parameters version)
string | $name | |
string | $pass | (optional), if absent set as the X-Plug-Master of the company |
string | $hwid | HWID the serial number |
array | $perm | (optional) PERM_FILTER if absent permit all |
array | $props | (optional) to initialize the custom properties |
array | $propLinks | (optional) PROP_LINKS to initialize properties links (not supported yet, present only for future use) |
getAuthId | ( | ) |
get authentication ID value.
getAuthPass | ( | ) |
get authentication password value.
getBaseUrl | ( | ) |
Gets the base REST server URL.
getDevice | ( | $plugid = NULL , |
|
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to read device's information and properties
string | $plugid | PLUG_ID |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
getDeviceLocation | ( | $data = NULL , |
|
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to get device location property (compact parameters version)
array | string | $data | array or JSON containing the following parameters: "id" => PLUG_ID |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
getDeviceLocationEx | ( | $plugid = NULL | ) |
This function performs an HTTP request to the server to get device location property (explicit parameters version)
string | $plugid | (optional) PLUG_ID the device id |
getDeviceProp | ( | $plugid = NULL , |
|
$prop = NULL , |
|||
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to read a device's properties (if "prop" is specified) or get all device's properties (if "prop" is not specified)
string | $plugid | (optional) PLUG_ID the device id |
string | $prop | property name |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
getLastErrorCode | ( | ) |
get the last error code ancountered.
getLastErrorString | ( | ) |
Switches the last encountered error code into a human readable message.
getLastHttpResultCode | ( | ) |
Gets the HTTP response status code of the last request.
getLastHttpResultString | ( | ) |
Switches the HTTP response status code of the last request into a human readable message.
getServerResponse | ( | ) |
returns the server response output of the last HTTP REST request
getTimeout | ( | ) |
get the timeout value.
hasSSL | ( | ) |
Checks whether SSL is enabled or not.
isAuthMaster | ( | ) |
Returns true if the requests will be performed as a master user, false otherwise
listChannels | ( | $data, | |
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to retrieve a list of channels refer already published data matching some criteria (compact parameters version)
array | string | $data | array or JSON string containing the following parameters: "channel_mask" => CHMASK "before" => (optional) TIMESTAMP or OBJECT_ID (OID of published data) "after" => (optional) TIMESTAMP or OBJECT_ID (OID of published data) "at" => (optional) TIMESTAMP_CSV "of" => (optional) PLUG_ID_CSV "offset" => (optional) Number: positive integer (including 0) "limit" => (optional) Number: positive integer (including 0) |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
listChannelsEx | ( | $channelMask, | |
$before = NULL , |
|||
$after = NULL , |
|||
$at = NULL , |
|||
$of = NULL , |
|||
$offset = NULL , |
|||
$limit = NULL |
|||
) |
This function performs an HTTP request to the server to retrieve a list of channels refer already published data matching some criteria (explicit parameters version)
string | $channelMask | (see: CHMASK) |
int | string | $before | (optional) TIMESTAMP or OBJECT_ID (OID of published data) |
int | string | $after | (optional) TIMESTAMP or OBJECT_ID (OID of published data) |
int | string | $at | (optional) TIMESTAMP_CSV |
string | $of | (optional) PLUG_ID_CSV |
int | $offset | (optional) Number: positive integer (including 0) |
int | $limit | (optional) Number: positive integer (including 0) |
publishData | ( | $data, | |
$channel = NULL , |
|||
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to publish data on the platform
array | string | $data | array or json encoded string containing the following keys: [ [ "id" => OBJECT_ID (optional), OID of the published data to update "channel" => CHANNEL, (optional), to override the channel in the url "data" => any valid JSON encodable value, "at" => TIMESTAMP,(optional) "of" => PLUG_ID, (optional), check if the X-Plug-Id is authorized for setting this field "expire_at" => TIMESTAMP, // (optional), expire date of this data entry "ttl" => int (optional), how many seconds this data entry will live (if "expire_at" is present, then this field is ignored) ], ... ] Note: the outer array is optional! |
string | $channel | (optional) if absent "channel" parameter is required in the data |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
removeData | ( | $data, | |
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to delete data ( Note: at least one of the following param is required: id, before, after or at) (compact parameters version)
array | string | $data | array or JSON string containing the following parameters: "channel_mask" => CHMASK "id" => (optional) OBJECT_ID_CSV or [OBJECT_ID,...] "before" => (optional) TIMESTAMP or OBJECT_ID (OID of published data) "after" => (optional) TIMESTAMP or OBJECT_ID (OID of published data) "at" => (optional) TIMESTAMP_CSV or [TIMESTAMP,...] "of" => (optional) PLUG_ID_CSV or [PLUG_ID,...] |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
removeDataEx | ( | $channelMask, | |
$id = NULL , |
|||
$before = NULL , |
|||
$after = NULL , |
|||
$at = NULL , |
|||
$of = NULL |
|||
) |
This function performs an HTTP request to the server to delete data ( Note: at least one of the following param is required: id, before, after or at) (explicit parameters version)
string | $channelMask | CHMASK |
string | array | $id | (optional) OBJECT_ID_CSV or [OBJECT_ID,...] |
int | string | $before | (optional) TIMESTAMP or OBJECT_ID (OID of published data) |
int | string | $after | (optional) TIMESTAMP or OBJECT_ID (OID of published data) |
int | string | array | $at | (optional) TIMESTAMP_CSV or [TIMESTAMP,...] |
string | array | $of | (optional) PLUG_ID_CSV or [PLUG_ID,...] |
removeDeviceProp | ( | $plugid, | |
$prop, | |||
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to remove a device's property
string | $plugid | PLUG_ID |
string | $prop | property name |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
retrieveData | ( | $data, | |
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to read published data (compact parameters version)
array | string | $data | array or JSON string containing the following parameters: "channel_mask" => CHMASK "before" => (optional) TIMESTAMP or OBJECT_ID (OID of published data) "after" => (optional) TIMESTAMP or OBJECT_ID (OID of published data) "at" => (optional) TIMESTAMP_CSV "of" => (optional) PLUG_ID_CSV "offset" => (optional) Number: positive integer (including 0) "limit" => (optional) Number: positive integer (including 0) |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
retrieveDataEx | ( | $channelMask, | |
$before = NULL , |
|||
$after = NULL , |
|||
$at = NULL , |
|||
$of = NULL , |
|||
$offset = NULL , |
|||
$limit = NULL |
|||
) |
This function performs an HTTP request to the server to read published data (explicit parameters version)
string | $channelMask | (see: CHMASK) |
int | string | $before | (optional) TIMESTAMP or OBJECT_ID (OID of published data) |
int | string | $after | (optional) TIMESTAMP or OBJECT_ID (OID of published data) |
int | string | $at | (optional) TIMESTAMP_CSV |
string | $of | (optional) PLUG_ID_CSV |
int | $offset | (optional) Number: positive integer (including 0) |
int | $limit | (optional) Number: positive integer (including 0) |
setAuth | ( | $id, | |
$pass, | |||
$is_master = FALSE |
|||
) |
Set the authentication credentials to be included in the requests headers.
string | $id | the id value. |
string | $pass | password value. |
bool | $is_master | specifies if the requests are performed as a master user or not. |
setAuthId | ( | $id | ) |
Sets Authentication ID value.
string | $id | The new ID value. |
setBaseUrl | ( | $url | ) |
Sets the base REST server URL.
string | $url | the base URL value. |
setCACert | ( | $certPath = NULL | ) |
Attempts to load an external certificate to verify the peer with when running over SSL
string | $certPath | The path to the certificate file |
setDebugMode | ( | $enabled | ) |
Sets debug mode on/off.
bool | $enabled | The new debug mode value. |
setDevice | ( | $data = NULL , |
|
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to modify a device's information or properties (compact parameters version)
array | string | $data | array or JSON string containing the following parameters: "id" => PLUG_ID (optional) "perm" => PERM_FILTER (optional) it contains just the sharing filters to modify "name" => String (optional) the device name "status" => STATUS (optional) "props" => array (optional) it contains just the properties to modify "prop_links" =>(optional), it contains a link reference to the published data (not supported yet, present only for future use. See: PROP_LINKS) |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
setDeviceEx | ( | $id = NULL , |
|
$perm = NULL , |
|||
$name = NULL , |
|||
$status = NULL , |
|||
$props = NULL , |
|||
$propLinks = NULL |
|||
) |
This function performs an HTTP request to the server to modify a device's information or properties (explicit parameters version)
string | $id | (see: PLUG_ID) |
array | $perm | (optional), it contains just the sharing filters to modify (see: PERM_FILTER) |
string | $name | (optional) the device name |
string | $status | (optional) (see: STATUS) |
array | $props | (optional), it contains just the properties to modify |
array | $propLinks | (optional), it contains a link reference to the published data (not supported yet, present only for future use. See: PROP_LINKS) |
setDeviceLocation | ( | $data, | |
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to set device location property (compact parameters version)
array | string | $data | array or JSON string containing the following parameters: "id" => PLUG_ID "x" => double (longitude) "y" => double (latitude) "r" => double (accuracy) "z" => double (altitude) "t" => string|int TIMESTAMP |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
setDeviceLocationEx | ( | $plugid, | |
$longitude, | |||
$latitude, | |||
$altitude, | |||
$accuracy, | |||
$timestamp | |||
) |
This function performs an HTTP request to the server to set device location property (explicit parameters version)
string | $plugid | PLUG_ID |
double | $longitude | |
double | $latitude | |
double | $altitude | |
double | $accuracy | |
string | number | $timestamp | TIMESTAMP |
setDeviceProp | ( | $plugid = NULL , |
|
$prop = NULL , |
|||
$value, | |||
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to write or delete device properties It can accept a single property ($prop = property name, $value = property value) or a set of properties ($prop = null, $value = object or array of all name=>value to write)
string | $plugid | (optional) PLUG_ID |
string | $prop | (optional), property name |
string | object | array | $value | properties values |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
setOptions | ( | $optionsArray | ) |
Sets class options.
array | $optionsArray | An associative array: "option name"=> value. Supported options: "outputFormat" => "json" or "array" or "object" (forces following requests ouput to be returned in that format) "debugMode"=> TRUE or FALSE (show/hide debug information) "timeout"=> int (max number of milliseconds to wait for server response) "id"=> String (set the authentication ID for following request) "pass" => String (set the authentication password to use) "isMaster"=> TRUE or FALSE (if authentication password refers to a master password) "baseUrl"=> String (the base URL to be used to perform remote HTTP requests) "enableSSL" => TRUE or FALSE (whether to enable SSL or not) |
setOutputFormat | ( | $format | ) |
Forces all requests to return server output in a specific data format.
string | $format | The new output format value. Can be "array", "object" or "json". |
setTimeout | ( | $seconds | ) |
Sets the timeout value for REST requests.
int | $seconds | the maximum waiting time (in seconds) for requests. |
uncontrolDevice | ( | $plugid = NULL , |
|
$plugidControlled = NULL , |
|||
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to unenroll a (controller) device
string | $plugid | (optional) PLUG_ID the controller PLUG_ID |
string | array | $plugidControlled | (optional) PLUG_ID or [ PLUG_ID, ... ] the device(s) to disassociate (default: all associated devices). |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
unenroll | ( | $data = NULL , |
|
$outputFormat = NULL |
|||
) |
This function performs an HTTP request to the server to remove a device (any: development, product or controller):
string | array | $data | PLUG_ID or [PLUG_ID,...] or PLUG_ID_CSV : The ids of the devices to be removed |
string | $outputFormat | (optional) the expected output format (will be overwritten if default outputFormat value is set) |
|
static |
const ACCURACY = "r" |
const AFTER = "after" |
const ALTITUDE = "z" |
const AT = "at" |
const AUTH = "auth" |
const BASEURL = "https://api.cloudplugs.com/iot/" |
const BEFORE = "before" |
const CHMASK = "channel_mask" |
const CONTENT_TYPE_JSON = "Content-type: application/json" |
const CTRL = "ctrl" |
const DATA = "data" |
const ERR_HEADER_MUST_BE_STRING = -6 |
const ERR_HTTP = -12 |
const ERR_INTERNAL = -1 |
const ERR_INVALID_CONTENT_LENGTH = -11 |
const ERR_INVALID_LOGIN = -8 |
const ERR_INVALID_PARAMETER = -7 |
const ERR_INVALID_SESSION = -3 |
const ERR_JSON_ENCODE = -10 |
const ERR_JSON_PARSE = -9 |
const ERR_NETWORK = -13 |
const ERR_OUT_OF_MEMORY = -2 |
const ERR_QUERY_INVALID_TYPE = -5 |
const ERR_QUERY_IS_NOT_OBJECT = -4 |
const FORMAT_ARRAY = 1 |
const FORMAT_JSON = 0 |
const FORMAT_OBJECT = 2 |
const HTTP_DELETE = 3 |
const HTTP_GET = 0 |
const HTTP_PATCH = 4 |
const HTTP_POST = 1 |
const HTTP_PUT = 2 |
const HTTP_RES_BAD_GATEWAY = 502 |
const HTTP_RES_BAD_REQUEST = 400 |
const HTTP_RES_CREATED = 201 |
const HTTP_RES_FORBIDDEN = 403 |
const HTTP_RES_MULTISTATUS = 207 |
const HTTP_RES_NOT_ACCEPTABLE = 406 |
const HTTP_RES_NOT_ALLOWED =405 |
const HTTP_RES_NOT_FOUND = 404 |
const HTTP_RES_NOT_IMPLEMENTED = 501 |
const HTTP_RES_OK = 200 |
const HTTP_RES_PAYMENT_REQUIRED = 402 |
const HTTP_RES_SERVER_ERROR = 500 |
const HTTP_RES_SERVICE_UNAVAILABLE = 503 |
const HTTP_RES_UNAUTHORIZED = 401 |
const HTTP_STR = "http://" |
const HTTPS_STR = "https://" |
const HWID = "hwid" |
const ID = "id" |
const LATITUDE = "y" |
const LIMIT = "limit" |
const LOCATION = "location" |
const LONGITUDE = "x" |
const MAX_LATITUDE = 90.0 |
const MAX_LONGITUDE = 180.0 |
const MIN_LATITUDE = -90.0 |
const MIN_LONGITUDE = -180.0 |
const MODEL = "model" |
const NAME = "name" |
const OF = "of" |
const OFFSET = "offset" |
const PASS = "pass" |
const PATH_CHANNEL = "channel" |
const PATH_DATA = "data" |
const PATH_DEVICE = "device" |
const PERM = "perm" |
const PLUG_AUTH_HEADER = "X-Plug-Auth: " |
const PLUG_EMAIL_HEADER = "X-Plug-Email: " |
const PLUG_ID_HEADER = "X-Plug-Id: " |
const PLUG_MASTER_HEADER = "X-Plug-Master: " |
const PROP_LINKS = "prop_links" |
const PROPS = "props" |
const STATUS = "status" |
const TIMEOUT = 60 |
const TIMESTAMP = "t" |
const TYPE_ACCURACY = 24 |
const TYPE_AFTER = 12 |
const TYPE_ALTITUDE = 25 |
const TYPE_AT = 19 |
const TYPE_AUTH = 16 |
const TYPE_BEFORE = 11 |
const TYPE_CHMASK = 20 |
const TYPE_CTRL = 1 |
const TYPE_DATA = 10 |
const TYPE_HWID = 2 |
const TYPE_ID = 17 |
const TYPE_LATITUDE = 23 |
const TYPE_LIMIT = 15 |
const TYPE_LOCATION = 21 |
const TYPE_LONGITUDE = 22 |
const TYPE_MODEL = 4 |
const TYPE_NAME = 3 |
const TYPE_OF = 13 |
const TYPE_OFFSET = 14 |
const TYPE_OID = 18 |
const TYPE_OID_ARR = 32 |
const TYPE_OID_CSV = 33 |
const TYPE_PASS = 5 |
const TYPE_PERM = 6 |
const TYPE_PLUG_ID = 27 |
const TYPE_PLUG_ID_ARR = 28 |
const TYPE_PLUG_ID_CSV = 29 |
const TYPE_PROP_LINKS = 9 |
const TYPE_PROPS = 7 |
const TYPE_STATUS = 8 |
const TYPE_TIMESTAMP = 26 |
const TYPE_TIMESTAMP_ARR = 30 |
const TYPE_TIMESTAMP_CSV = 31 |