Now that your HostedHooks instance has been setup (previous step), we are now ready to start integrating HostedHooks into your App.
1. Pick your programming language
The HostedHooks API can be used easily with most programming languages. We will add code samples for several of them in this guide.
Ruby
PHP
Javascript
Laravel
2. Set environment variables
The HostedHooks API key is required for all API requests. It should be kept secret and set as an environment variable.
HOSTEDHOOKS_API_KEY='VdaYqFdqwrtqmQr6tJTuEBF1'
3. Copy your App identifier
Before we jump into the code we will need to grab your App identifier (ID) from the HostedHooks dashboard. Once at your dashboard, click View on your App and then click the copy icon to grab the unique ID of your app object.
3. Send a webhook message
In this step we will walk through how you trigger sending webhooks from your app.
The endpoint to send messages is documented here. The URI for that endpoint is below. It has one parameter, the app_id which you copied from the dashboard in the previous step.
In addition to the app_id, the event_type is used to determine which subscribers will receive your webhook messages.
If you need to send webhooks to a specific subscriber's endpoint, you can use the API endpoint documented here.
The data object within the message payload is an open JSON object that allows you to pass in any information that you want. The data inside this payload will be passed on to your subscribers via the webhook endpoint they setup.
Once you've received a successful response, you've successfully triggered a webhook call from your app. We will now review the subscriber side to receive the webhook you sent.