public async Task PostUnsubscribe(string subId) { // Get our WebHook Client InstagramWebHookClient client = Dependencies.Client; // Unsubscribe from the given subscription using client configuration with id="". await client.UnsubscribeAsync("", subId); }
public async Task PostUnsubscribeAll() { // Get our WebHook Client InstagramWebHookClient client = Dependencies.Client; // Unsubscribe from all subscriptions for the client configuration with id="". await client.UnsubscribeAsync(""); }
public async Task <IHttpActionResult> PostSubscribe() { // Get our WebHook Client InstagramWebHookClient client = Dependencies.Client; // Subscribe to a geo location, in this case within 5000 meters of Times Square in NY var sub = await client.SubscribeAsync(string.Empty, Url, 40.757626, -73.985794, 5000); return(Ok(sub)); }
/// <summary> /// Subscribes to a geographic area identified by a center latitude and longitude and a radius extending from the center. /// </summary> /// <param name="client">The current <see cref="InstagramWebHookClient"/> instance.</param> /// <param name="id">A (potentially empty) ID of a particular configuration for this WebHook. This makes it possible to /// support multiple WebHooks with individual configurations.</param> /// <param name="urlHelper">A <see cref="UrlHelper"/> for computing the callback URI.</param> /// <param name="latitude">The center latitude of the geo-area to subscribe to.</param> /// <param name="longitude">The center longitude of the geo-area to subscribe to.</param> /// <param name="radius">The radius of the geo-area in meters between 0 and 5000.</param> /// <returns>A <see cref="InstagramSubscription"/> instance.</returns> public static Task <InstagramSubscription> SubscribeAsync(this InstagramWebHookClient client, string id, UrlHelper urlHelper, double latitude, double longitude, int radius) { if (client == null) { throw new ArgumentNullException("client"); } if (urlHelper == null) { throw new ArgumentNullException("urlHelper"); } Uri callback = GetCallback(id, urlHelper); return(client.SubscribeAsync(id, callback, latitude, longitude, radius)); }
public override async Task ExecuteAsync(string generator, WebHookHandlerContext context) { // Get the WebHook client InstagramWebHookClient client = Dependencies.Client; // Convert the incoming data to a collection of InstagramNotifications var notifications = context.GetDataOrDefault <IEnumerable <InstagramNotification> >(); foreach (var notification in notifications) { // Use WebHook client to get detailed information about the posted media var entries = await client.GetRecentGeoMedia(context.Id, notification.ObjectId); foreach (JToken entry in entries) { // Get direct links and sizes of media var thumbnail = entry["images"]["thumbnail"].ToObject <InstagramMedia>(); var lowres = entry["images"]["low_resolution"].ToObject <InstagramMedia>(); var std = entry["images"]["standard_resolution"].ToObject <InstagramMedia>(); } } }
public override async Task ExecuteAsync(string generator, WebHookHandlerContext context) { // Get the WebHook client InstagramWebHookClient client = Dependencies.Client; // Convert the incoming data to a collection of InstagramNotifications var notifications = context.GetDataOrDefault <InstagramNotificationCollection>(); foreach (var notification in notifications) { // Use WebHook client to get detailed information about the posted media JArray entries = await client.GetRecentGeoMedia(context.Id, notification.ObjectId); foreach (JToken entry in entries) { InstagramPost post = entry.ToObject <InstagramPost>(); // Image information if (post.Images != null) { InstagramMedia thumbnail = post.Images.Thumbnail; InstagramMedia lowRes = post.Images.LowResolution; InstagramMedia stdRes = post.Images.StandardResolution; } // Video information if (post.Videos != null) { InstagramMedia lowBandwidth = post.Videos.LowBandwidth; InstagramMedia lowRes = post.Videos.LowResolution; InstagramMedia stdRes = post.Videos.StandardResolution; } // Get direct links and sizes of media Uri link = post.Link; } } }
public static void Initialise(HttpConfiguration config) { client = new InstagramWebHookClient(config); }