public string InstagramFeed() { try { // Get feed from cache if possible var cacheKey = string.Format(ModelCacheEventConsumer.INSTAGRAM_FEEDS_KEY); var feed = _cacheManager.Get<string>(cacheKey); if (!string.IsNullOrEmpty(feed)) return feed; //no value in the cache yet so let's retrieve it int count; if (!Int32.TryParse(ConfigurationManager.AppSettings["Instagram.MediaCount"], out count)) { count = 3; } var im = new InstagramManager(); feed = im.GetRecentMedia(ConfigurationManager.AppSettings["Instagram.ClientId"], ConfigurationManager.AppSettings["Instagram.UserId"], count); int cacheDuration; if (!Int32.TryParse(ConfigurationManager.AppSettings["Instagram.CacheDuration"], out cacheDuration)) { cacheDuration = 10; // 10 minutes } //let's cache the result _cacheManager.Set(cacheKey, feed, cacheDuration); return feed; } catch (Exception ex) { _logger.Error(ex.Message, ex); return string.Empty; } }
public string InstagramCallback() { try { var code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { return string.Empty; } var im = new InstagramManager(); return im.GetAuthToken( ConfigurationManager.AppSettings["Instagram.ClientId"], ConfigurationManager.AppSettings["Instagram.ClientSecret"], ConfigurationManager.AppSettings["Instagram.CallbackUrl"], code); } catch (Exception ex) { _logger.Error(ex.Message, ex); return string.Empty; } }