What is Notification Message?
If you have provided us a postback url, Ankoder will POST a notification message after each step of the process. The body of the POST request consists of two parameters, the Message and Signature.
Types of Notifications
- Download or NewVideo
- Convert: completion of transcoding job.
- Upload: completion of transferring to external storage.
Message
It is a URL-escaped JSON-encoded hash containing key-value pairs relevant to the outcome report.
Example:
%7B%22result%22%3A%22success%22%2C%22video_id%22%3A%22177%22%2C%22video_name%22%3A%222ff52118732cc3e7932f34c12c6818c30cabe57c.flv%22%2C%22type%22%3A%22Download%22%2C%22error%22%3A%22%22%7D
Signature
It is the URL-escaped string of Base64-encoded HMAC-SHA1 digest of your private key and the URL-unescaped message. It should be checked to validate the notification comes from Ankoder.
Example:
zrfUIp3p6BBXrBMIBUDSjzrGv8Q%3D
Example code in Ruby
Extracting JSON message
require "cgi"
require "json"
extracted_hash = JSON.parse CGI.escape(params[:message])
Validating Signature
require "hmac-sha1"
require "cgi"
require "base64"
encoded_signature = CGI.escape Base64.encode64(HMAC::SHA1::digest(private_key, CGI.unescape(message))).strip
encoded_signature == params[:signature]
Testing
To test receiving messages quickly, we recommend Postbin.org
