« Back to Product

Documentation

RegisterHook

Require: IP-Symcon >= 8.1

 boolean RegisterHook (string $Adress) 

Parameters

Adress

Address of the hook

Returns

If the command could be executed successfully, the result is TRUE, otherwise FALSE.

Description

This function registers a webhook with the address in Webhook Control. This can then be accessed from outside via 127.0.0.1:3777/hook/address, where address describes the address parameter. If this registered webhook is called, the function ProcessHookData of this module is called.

The registered webhook is volatile. On a restart, it is removed until the RegisterHook function is executed again by the instance, which typically happens as part of the restart in Create. This means that the module does not have to clean up when it is deleted and the WebHook is automatically removed when the instance is deleted.

Warning

This function can normally only be used for IPSModuleStrict. For the old IPSModule, however, the base class WebHookModule can be downloaded and extended. However, the functionality of the base class is not recommended for IPSModuleStrict, as a webhook registered in this way is not volatile and must therefore be cleaned up manually.

Example

// IPSModuleStrict
public function Create(): void {

    // Do not remove this line
    parent::Create();

    $this->RegisterHook('my-module');
}

// IPSModule
// This function can only be used natively for IPSModuleStrict
// Using the base class WebHookModule enables a comparable use in IPSModule
Any questions?