Please provide a valid credit card using the credit card form on the billing page. Update Card Details
This API creates a SEVU ticket. This ticket allows a user to view a protected video. This system allows you to restrict access to a specific video or subset of videos, to a specific IP address, timeframe and usage count.
using System; using System.IO; using System.Net; using System.Security.Cryptography; using System.Text; using Newtonsoft.Json.Linq; using RestSharp; namespace ConsoleApplication1 { internal class Program { /** * Before you can use this example. * You should references to Newtonsoft.Json.Linq and RestSharp * It can be done with Nuget Packgage manager console * PM> Install-Package Newtonsoft.Json * PM> Install-Package RestSharp * Or you download it from : * https://www.nuget.org/packages/Newtonsoft.Json/ * https://www.nuget.org/packages/RestSharp/ * */ private static void Main(string[] args) { var api_key = "[API KEY]"; var cdn = 0; // CDN NUMBER var privateKey = "[PRIVATE KEY]"; var video = "[PATH TO YOUR VIDEO]"; var app = "[YOUR APP NAME]"; var content = CreateSevuTicket(api_key, cdn, app, video, privateKey); Console.Write(content); Console.WriteLine("Press ESC to stop"); do { while (!Console.KeyAvailable) { // Do something } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); } private static string CreateSevuTicket(string api_key, int cdn, string app, string video, string privateKey) { var data = new JObject(); data["command"] = "sevu.request"; data["api_key"] = api_key; data["timestamp"] = ((Int32) (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds); data["cdn"] = cdn; data["app"] = app; data["video"] = video; data["pass"] = Guid.NewGuid().ToString(); data["ip"] = "0.0.0.0/0"; data["uses"] = 5; data["expires"] = string.Format("{0:yyyy-MM-dd H:mm:ss}", DateTime.Now.AddDays(1)); var str = data.ToString().Replace("\r\n", "").Replace(" ", "").Replace("/", "\\/"); var s = CreateSignature(str, privateKey); data["signature"] = s; var postData = data.ToString().Replace("\r\n", "").Replace(" ", "").Replace("/", "\\/"); var restClient = new RestClient("https://api.scaleengine.net:443/stable/"); var request = new RestRequest("", Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Content-Length", Convert.ToString(postData.Length + 5)); request.AddParameter("json", postData); var response = restClient.Execute(request); var content = response.Content; return content; } private static string CreateSignature(string message, string secret) { secret = secret ?? ""; var encoding = new ASCIIEncoding(); byte[] keyByte = encoding.GetBytes(secret); byte[] messageBytes = encoding.GetBytes(message); using (var hmacsha256 = new HMACSHA256(keyByte)) { byte[] hashmessage = hmacsha256.ComputeHash(messageBytes); return Convert.ToBase64String(hashmessage); } } } }
command | [REQUIRED] [string] - API command to execute |
cdn | [REQUIRED] [int] - The ScaleEngine CDN ID of your account |
api_key | [REQUIRED] [string] - The API key provided as part of your account |
timestamp | [REQUIRED] [int] - The unix timestamp of your request, used to prevent authenticated API requests from being replayed |
app | [REQUIRED]
|
video | [REQUIRED]
|
pass | [REQUIRED] [string] - A randomly generated password. Should be unique for each request. Recommended length atleast 10 characters. |
ip | [REQUIRED]
|
uses | [REQUIRED] [int] - The number of times the video will be allowed to start. This can be used to restrict how many times a ticket may be used, and helps further protect against account sharing |
expires | [REQUIRED] [datetime] - The expiration date of the ticket. After
this time, access will no longer be allowed, the user will
require a new ticket.
Example: 2023-12-04 18:46:51 |
{ "code": 2002, "message": "ScaleEngine Virtual Usher Ticket Granted", "status": "success", "ticket": { "key": "mystream.53ffc996dd39d5.39102367", "pass": "g63clVAI5wFPxY9vwVOJvw6L", "ip": "0.0.0.0/0", "video": "mystream", "app": "myapp-sevu", "created_date": "2014-08-29 00:30:14", "used_date": "0000-00-00 00:00:00", "uses": "5", "active": "1" }, "handle_time":"0.3795 seconds" }
code | [int] - API Response Code | ||||||||||||||||||
message | [string] - Debugging message | ||||||||||||||||||
status | [string] - "success" or "failure" | ||||||||||||||||||
ticket |
|
||||||||||||||||||
handle_time | [float] - The amount of time spent processing your request |