public static async void LikeInsta(InstaSharp.Models.Media selectedPost) { if (selectedPost != null) { var authInfo = new OAuth(_config); var authResponse = new InstaSharp.Models.Responses.OAuthResponse(); var response = await _user.GetSelf(); authResponse.AccessToken = Access; authResponse.User = response.Data; var likes = new Likes(_config, authResponse); if (selectedPost.UserHasLiked == true) { await likes.Delete(selectedPost.Id); selectedPost.UserHasLiked = false; await _metroWindow.ShowMessageAsync("Instagram", "Cofnięto Like'a!"); } else { await likes.Post(selectedPost.Id); selectedPost.UserHasLiked = true; await _metroWindow.ShowMessageAsync("Instagram", "Dodano Like'a!"); } } else { await _metroWindow.ShowMessageAsync("", "Nie wybrano posta"); } }
public static async void Comment(InstaSharp.Models.Media selectedPost, string comentText) { if (selectedPost != null) { var authInfo = new OAuth(_config); var thing = new InstaSharp.Models.Responses.OAuthResponse(); var response = await _user.GetSelf(); thing.AccessToken = Access; thing.User = response.Data; var comments = new Comments(_config, thing); await comments.Post(selectedPost.Id, comentText); await _metroWindow.ShowMessageAsync("Instagram", "Opublikowano komentarz!"); } else { await _metroWindow.ShowMessageAsync("", "Nie wybrano posta"); } }
// Utils // private IMediaCharacteristics IterateMedia(IMediaCharacteristics m, InstaSharp.Models.Media item) { m.Attribution = _mappers[MapperTypes.Attribution].Map <Attribution>(item.Attribution); m.Caption = _mappers[MapperTypes.Caption].Map <Caption>(item.Caption); if (m.Caption != null) { m.Caption.From = _mappers[MapperTypes.UserInfo].Map <UserInfo>(item.Caption.From); } m.Comments = _mappers[MapperTypes.Comments].Map <Domain.Media.Comments>(item.Comments); m.Images = _mappers[MapperTypes.Image].Map <Domain.Media.Image>(item.Images); m.Images.Thumbnail = _mappers[MapperTypes.Resolution].Map <Domain.Media.Resolution>(item.Images.Thumbnail); m.Images.LowResolution = _mappers[MapperTypes.Resolution].Map <Domain.Media.Resolution>(item.Images.LowResolution); m.Images.StandardResolution = _mappers[MapperTypes.Resolution].Map <Resolution>(item.Images.StandardResolution); m.Likes = _mappers[MapperTypes.Likes].Map <Domain.Media.Likes>(item.Likes); if (item.Location != null) { m.Location = _mappers[MapperTypes.Location].Map <Domain.Media.Location>(item.Location); } m.User = _mappers[MapperTypes.UserInfo].Map <UserInfo>(item.User); if (item.GetType() == typeof(List <UserInPhoto>)) /// TODO Check if this works/necesssary { foreach (var u in m.UsersInPhoto) { m.UsersInPhoto.Add(_mappers[MapperTypes.UserInPhoto].Map <UserInPhoto>(u)); } } if (item.Type == "video") { m.Videos = _mappers[MapperTypes.Video].Map <Video>(item.Videos); m.Videos.LowResolution = _mappers[MapperTypes.Resolution].Map <Resolution>(item.Videos.LowResolution); m.Videos.StandardResolution = _mappers[MapperTypes.Resolution].Map <Resolution>(item.Videos.StandardResolution); } return(m); }