public BackgroundModule()
{
Get["/background", true] = async (y, ct) =>
{
using (var client = new WebClient())
{
var json = client.DownloadString(new Uri("https://api.instagram.com/v1/users/2261366739/media/recent?access_token=" + ConfigurationManager.AppSettings["access_token"]));
var parsedJson = JsonConvert.DeserializeObject<Rootobject>(json);
var publishedImages = parsedJson.data.Where(x => x.type == "image").Select(x => new PublishedImage
{
Caption = x.caption == null ? "" : x.caption.text,
Url = x.images.standard_resolution.url,
Location = x.location == null ? "" : x.location.name,
}).ToList();
var serializedJson = JsonConvert.SerializeObject(publishedImages);
await PublishToGitAsync(serializedJson);
return null;
}
};
}