Skip to content

Instantly share code, notes, and snippets.

@jawsthegame
Created April 25, 2012 16:13
Show Gist options
  • Save jawsthegame/2490993 to your computer and use it in GitHub Desktop.
Save jawsthegame/2490993 to your computer and use it in GitHub Desktop.
Examples for Vistar Media .Net Client
var adRequest = new AdRequest {
NetworkId = "YOUR_NETWORK_ID",
ApiKey = "YOUR_API_KEY",
DeviceId = "YOUR_DEVICE_ID",
NumberOfScreens = 1,
DirectConnection = false,
DisplayAreas = new List<DisplayArea> {
new DisplayArea{
Id = "YOUR_DISPLAY_AREA_ID",
Width = 1280,
Height = 720,
AllowAudio = true,
SupportedMedia = new List<string> {
"image/gif",
"image/jpeg",
"image/png",
"application/x-shockwave-flash",
"video/x-flv",
"video/mp4"
}
}
}
}
adRequest.SetDisplayTime(DateTime.Now); // This setter will translate your local time to a UTC epoch time format.
var client = new ApiClient();
var advertisement = client.SubmitAdRequest(adRequest);
var adRequest = new AdRequest {
NetworkId = "YOUR_NETWORK_ID",
ApiKey = "YOUR_API_KEY",
DeviceId = "YOUR_DEVICE_ID",
NumberOfScreens = 1,
DirectConnection = false,
DisplayAreas = new List<DisplayArea> {
new DisplayArea{
Id = "YOUR_DISPLAY_AREA_ID",
Width = 1280,
Height = 720,
AllowAudio = true,
SupportedMedia = new List<string> {
"image/gif",
"image/jpeg",
"image/png",
"application/x-shockwave-flash",
"video/x-flv",
"video/mp4"
}
}
}
}
adRequest.SetDisplayTime(DateTime.Now); // This setter will translate your local time to a UTC epoch time format.
var requests = new List<AdRequest> { adRequest }; // You may send any number of ad requests
var client = new ApiClientAsync();
var tasks = client.SubmitAdRequestsAsync(adRequest); // This call will return List<Task<List<Advertisement>>>
/*
* The Task<List<Advertisement>> objects that will be returned from this call will be populated asynchronously with your Advertisement(s)
*
* You may either wait for these by using System.Threading.Tasks.Task.WaitAll(tasks.ToArray()) or loop and check on [TASK_OBJECT].IsCompleted
*/
Task.WaitAll(tasks.ToArray());
var advertisements = tasks.SelectMany(t => t.Result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment