Working with webhooks from Node SDK
Node SDK offers you a way to work with webhooks through the API.
Webhooks are great to know what is happening by simply listening on your server for things to happen. See bellow how you can use our API in regards to webhooks.
NodeJS SDK Webooks Methods
- create Create a new webhook for the given url to catch the given events.
ZiggeoSdk.Webhooks.create(arguments, [callbacks])
- target_url The url that will catch the events
- encoding Data encoding to be used by the webhook to send the events.
- events Comma-separated list of the events the webhook will catch. They must be valid webhook type events.
This method returns stringExample:/* Usage: node webhooks_create.js APP_TOKEN PRIVATE_KEY TARGET_URL ENCODING "EVENTS1,EVENTS2" Sample: node webhooks_create.js 1234567890abcdef 1234567890abcdef http://example.com jsonheader video_delete,video_create */ var app_token = process.argv[2]; var private_key = process.argv[3]; var target_url = process.argv[4]; var encoding = process.argv[5]; var events = process.argv[6]; var Ziggeo = require("../index.js"); var ZiggeoSdk = new Ziggeo(app_token, private_key); var options = { target_url: target_url, encoding: encoding, // json, form, jsonheader events: events } ZiggeoSdk.Webhooks.create(options,{ success: function(data){ console.log("Created webhook token "+data); }, failure: function(error){ console.log(error); } });
- confirm Confirm a webhook using its ID and the corresponding validation code.
ZiggeoSdk.Webhooks.confirm(arguments, [callbacks])
- webhook_id Webhook ID that's returned in the creation call.
- validation_code Validation code that is sent to the webhook when created.
This method returns string - delete Delete a webhook using its URL.
ZiggeoSdk.Webhooks.destroy(arguments, [callbacks])
- target_url The url that will catch the events
This method returns string