« Back to Product

Documentation

ProcessHookData

Require: IP-Symcon >= 4.0

 void ProcessHookData ()

Returns

No return

Description

If the WebHook registered by the function RegisterHook is called from outside, this function is executed. The output of this function (e.g. through echo) is returned to the caller. The header of the response can also be adapted using corresponding PHP functions.

Example

// IPSModuleStrict
protected function ProcessHookData(): void {
    // Received data
    $data = json_decode(file_get_contents('php://input'), true);
    $this->LogMessage('Remote Method', utf8_decode($data['method']), KL_MESSAGE);

    if ($data['method'] == 'get_version') {
        header('Content-Type: application/json');

        echo json_encode([
            'result' => IPS_GetKernelVersion(),
            'jsonrpc' => '2.0',
            'id' => $request['id']
        ]);
    }
}

// IPSModule
protected function ProcessHookData($JSONString) {

    // Example is identical. Please note the changed function signature.

}
Any questions?