public async static Task CheckSomething() { if (_instaApi.IsUserAuthenticated) { IResult <InstaMedia> mediaItem = await _instaApi.GetMediaByIdAsync("1918376805137779938"); //System.Diagnostics.Debug.Write("\nUser zalogowany!\nUser: "******"\nUser niezalogowany..."); } }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { IResult <InstaUserInfo> userinfo = await _instaApi.GetUserInfoByIdAsync(_userSession.LoggedInUder.Pk); IResult <InstaUser> user = await _instaApi.GetUserAsync("aeroflot"); IResult <InstaUserInfo> info = await _instaApi.GetUserInfoByIdAsync(user.Value.Pk); IResult <InstaUserShortList> folows = await _instaApi.GetUserFollowersAsync(_userSession.UserName, PaginationParameters.Empty); IResult <InstaMedia> userinfo2 = await _instaApi.GetMediaByIdAsync(folows.Value[43].ProfilePictureId); using (HttpClient client = new HttpClient()) { HttpResponseMessage imageResponse = await client.GetAsync(userinfo2.Value.Images[0].URI); //InMemoryRandomAccessStream randomAccess = new InMemoryRandomAccessStream(); //DataWriter writer = new DataWriter(randomAccess.GetOutputStreamAt(0)); //writer.WriteBytes(await imageResponse.Content.ReadAsByteArrayAsync()); //await writer.StoreAsync(); //BitmapImage bm = new BitmapImage(); //await bm.SetSourceAsync(randomAccess); //myImg.Source = bm; } }
private async Task DownloadUrlPhotoAsync(string input, InputMediaType inputType) { try { var statsFile = $@"{_statsDirectory}\urls.csv"; IResult <string> mediaIdFromUrl = null; if (!File.Exists(statsFile)) { using (var csv = new Csv(statsFile, _delimiter)) { csv.WriteHeader(); } } if (inputType == InputMediaType.Url) { mediaIdFromUrl = await _instaApi.GetMediaIdFromUrlAsync(new Uri(input)); if (!mediaIdFromUrl.Succeeded) { return; } } var mediaId = mediaIdFromUrl == null ? input : mediaIdFromUrl.Value; var mediaInformation = await _instaApi.GetMediaByIdAsync(mediaId); if (!mediaInformation.Succeeded) { return; } _cancellationToken.ThrowIfCancellationRequested(); if (_mediaFilter.CheckFilters(mediaInformation.Value)) { return; } if (CheckTotalDownloads()) { await DownloadInstaMediaAsync(mediaInformation.Value, statsFile); } } catch (Exception) { // something probably went wrong } }