public static InstaImageUpload AsUpload( this InstaImage image, InstaMedia media, string uri) { var imageUpload = new InstaImageUpload(uri, image.Width, image.Height); var tagsUpload = new List <InstaUserTagUpload>(); if (media.UserTags != null) { foreach (var tag in media.UserTags) { var tagUpload = new InstaUserTagUpload(); if (tag.User != null) { tagUpload.Username = tag.User.UserName; } if (tag.Position != null) { tagUpload.X = tag.Position.X; tagUpload.Y = tag.Position.Y; } tagsUpload.Add(tagUpload); } } imageUpload.UserTags.AddRange(tagsUpload); return(imageUpload); }
/// <summary> /// Upload video /// </summary> /// <param name="video">Video to upload</param> /// <param name="imageThumbnail">Image thumbnail</param> /// <param name="caption">Caption</param> /// <returns></returns> public async Task <IResult <InstaMedia> > UploadVideoAsync(InstaVideo video, InstaImage imageThumbnail, string caption) { ValidateUser(); ValidateLoggedIn(); return(await _mediaProcessor.UploadVideoAsync(video, imageThumbnail, caption)); }
public async void UploadImagesAsAlbumTest() { Assert.True(_authInfo.ApiInstance.IsUserAuthenticated); var mediaImage = new InstaImage { Height = 512, Width = 512, URI = new Uri(@"C:\tmp\1.jpg", UriKind.Absolute).LocalPath }; var mediaImage1 = new InstaImage { Height = 512, Width = 512, URI = new Uri(@"C:\tmp\2.jpg", UriKind.Absolute).LocalPath }; var result = await _authInfo.ApiInstance.UploadPhotosAlbumAsync(new[] { mediaImage, mediaImage1 }, "Collection of design"); //assert Assert.True(result.Succeeded); Assert.NotNull(result.Value); }
/// <summary> /// Configure story photo /// </summary> /// <param name="image">Photo to configure</param> /// <param name="uploadId">Upload id</param> /// <param name="caption">Caption</param> /// <returns></returns> public async Task <IResult <InstaStoryMedia> > ConfigureStoryPhotoAsync(InstaImage image, string uploadId, string caption) { ValidateUser(); ValidateLoggedIn(); return(await _storyProcessor.ConfigureStoryPhotoAsync(image, uploadId, caption)); }
async void Posting() { string message = post.Message; if (post.AlbumFileNamePhoto == null) { var mediaImage = new InstaImage { Height = 1080, Width = 1350, URI = post.FileNamePhoto }; var result = await api.UploadPhotoAsync(mediaImage, message); } if (post.AlbumFileNamePhoto != null && post.AlbumFileNamePhoto.Length > 1) { InstaImage[] img = new InstaImage[post.AlbumFileNamePhoto.Length]; for (int i = 0; i < post.AlbumFileNamePhoto.Length; i++) { img[i] = new InstaImage { Height = 1080, Width = 1350, URI = post.AlbumFileNamePhoto[i] }; } var result = await api.UploadPhotosAlbumAsync(img, message); } infoAcc.Status = "Опубликовано"; EventUpdateGrid(this, new UpdateGridAutopost(infoAcc)); }
public async void ShareMediaAsStory() { // You can share an media to an story (photo, video and album) // Note that you must draw whatever(photo, video and album) you want in your image first! // Also it's on you to calculate clickable media but mostly is 0.5 for width and height var mediaPk = 1912406543385492359; // Get it from InstaMedia.Pk, you can use video or album pk too! var mediaStory = new InstaMediaStoryUpload { X = 0.5, // center of photo Y = 0.5, // center of photo Width = 0.5, // height of clickable media, it's an square in center of photo Height = 0.5, // width of clickable media, it's an square in center of photo Rotation = 0, // don't change this MediaPk = mediaPk }; var image = new InstaImage { Uri = @"c:\someawesomepicture.jpg" }; var result = await api.StoryProcessor.ShareMediaAsStoryAsync(image, mediaStory).ConfigureAwait(false); Console.WriteLine(result.Succeeded ? $"Story created from an media post: {result.Value.Media.Pk}" : $"Unable to share media as story: {result.Info.Message}"); }
public static async void UploadPics(Rootobject pics) { int picsAmnt = (int)pics.data.children.GetLongLength(0); int width = 0; int height = 0; for (int i = 0; i < picsAmnt; i++) { WebRequest request = WebRequest.Create(pics.data.children[i].data.url); WebResponse response = request.GetResponse(); System.IO.Stream responseStream = response.GetResponseStream(); Bitmap photo = new Bitmap(responseStream); width = photo.Width; height = photo.Height; photo.Save("exampleSaved1" + ".jpg", ImageFormat.Jpeg); // to debug local files saved //InstaImage img = new InstaImage(pics.data.children[i].data.url, width, height); InstaImage img = new InstaImage(@"C:\Users\ttrub\Desktop\InstagramATBGEBot\InstagramATBGEBot\InstagramATBGEBot\bin\Debug\exampleSaved1.jpg", width, height); var result = await api.UploadPhotoAsync(img, "Uploaded by: " + pics.data.children[i].data.author + "; " + pics.data.children[i].data.title); } }
public async Task UploadPhotosAlbumAsync(Post post) { if (post.Images != null && post.Images.Count > 0) { List <InstaImage> listInstaImage = new List <InstaImage>(); foreach (Image image in post.Images.ToList()) { var mediaImage = new InstaImage { Height = 1080, Width = 1080, URI = new Uri(Path.GetFullPath(image.PathResize), UriKind.Absolute).LocalPath }; listInstaImage.Add(mediaImage); } var result = await _instaApi.UploadPhotosAlbumAsync(listInstaImage.ToArray(), post.Subtitle); post.IsPosted = result.Succeeded; if (!result.Succeeded) { throw new Exception("Falha ao postar fotos: " + result.Info.Message); } } else { throw new Exception("O post não possui imagem associada!"); } }
public void AddRequest(QiskitRequest request, InstaImage image) { request.Normalise(); requests.Enqueue(new Request() { request = request, image = image }); }
public static InstaVideoUpload AsUpload( this InstaVideo video, string uri) { video.VideoBytes = File.ReadAllBytes(uri); var thumbnail = new InstaImage(); return(new InstaVideoUpload(video, thumbnail)); }
public static InstaImageUpload ConvertToImageUpload(this InstaImage instaImage, InstaUserTagUpload[] userTags = null) { return(new InstaImageUpload { Height = instaImage.Height, ImageBytes = instaImage.ImageBytes, Uri = instaImage.Uri, Width = instaImage.Width, UserTags = userTags?.ToList() }); }
public async void UploadPhoto() { var image = new InstaImage { Uri = @"c:\someawesomepicture.jpg" }; var result = await api.StoryProcessor.UploadStoryPhotoAsync(image, "someawesomepicture").ConfigureAwait(false); Console.WriteLine(result.Succeeded ? $"Story created: {result.Value.Media.Pk}" : $"Unable to upload photo story: {result.Info.Message}"); }
async void Posting() { string message = post.Message; var mediaImage = new InstaImage { Height = 1920, Width = 1080, URI = post.FileNamePhoto }; var result = await api.UploadStoryPhotoAsync(mediaImage, message); infoAcc.Status = "Опубликовано"; EventUpdateGrid(this, new UpdateGridAutopost(infoAcc)); }
public async Task DoShow() { var mediaImage = new InstaImage { Height = 1080, Width = 1080, URI = new Uri(Path.GetFullPath(@"c:\someawesomepicture.jpg"), UriKind.Absolute).LocalPath }; var result = await _instaApi.UploadPhotoAsync(mediaImage, "someawesomepicture"); Console.WriteLine(result.Succeeded ? $"Media created: {result.Value.Pk}, {result.Value.Caption}" : $"Unable to upload photo: {result.Info.Message}"); }
public async Task DoShow() { var mediaImage = new InstaImage { // leave zero, if you don't know how height and width is it. Height = 1080, Width = 1080, URI = @"c:\someawesomepicture.jpg" }; var result = await _instaApi.MediaProcessor.UploadPhotoAsync(mediaImage, "someawesomepicture"); Console.WriteLine(result.Succeeded ? $"Media created: {result.Value.Pk}, {result.Value.Caption}" : $"Unable to upload photo: {result.Info.Message}"); }
public async Task DoShow() { var mediaVideo = new InstaVideo(@"c:\somevideo.mp4", 1080, 1080, 3); var mediaImage = new InstaImage { Height = 1080, Width = 1080, URI = new Uri(Path.GetFullPath(@"c:\RamtinJokar.jpg"), UriKind.Absolute).LocalPath }; var result = await _instaApi.UploadVideoAsync(mediaVideo, mediaImage, "ramtinak"); Console.WriteLine(result.Succeeded ? $"Media created: {result.Value.Pk}, {result.Value.Caption}" : $"Unable to upload video: {result.Info.Message}"); }
async void Posting() { string message = post.Message; var mediaVideo = new InstaVideo(post.FileNameVideo, 1080, 1080, 3); var mediaImage = new InstaImage { Height = 1080, Width = 1080, URI = post.FileNamePreview }; var result = await api.UploadVideoAsync(mediaVideo, mediaImage, message); infoAcc.Status = "Опубликовано"; EventUpdateGrid(this, new UpdateGridAutopost(infoAcc)); }
public async void UploadStoryImageTest() { Assert.True(_authInfo.ApiInstance.IsUserAuthenticated); var mediaImage = new InstaImage { Height = 1200, Width = 640, URI = new Uri(@"C:\test.jpg", UriKind.Absolute).LocalPath }; var result = await _authInfo.ApiInstance.UploadStoryPhotoAsync(mediaImage, "Lake"); Assert.True(result.Succeeded); Assert.NotNull(result.Value); }
public async Task UploadImg(string caption, string localPath) { var mediaImage = new InstaImage { Height = 1080, Width = 1080, URI = new Uri(Path.GetFullPath(localPath), UriKind.Absolute).LocalPath }; var result = await _instaApi.UploadPhotoAsync(mediaImage, caption); Console.WriteLine(result.Succeeded ? $"Media created: {result.Value.Pk}, {result.Value.Caption}" : $"Unable to upload photo: {result.Info.Message}"); Console.ReadLine(); }
private static async Task SendBuffer(InstaDirectInboxThreadWrapper thread, IBuffer buffer, int imageWidth, int imageHeight, Action <UploaderProgress> progress) { var instaImage = new InstaImage { UploadBuffer = buffer, Width = imageWidth, Height = imageHeight }; if (string.IsNullOrEmpty(thread.ThreadId)) { return; } var uploadId = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); await Api.SendDirectPhotoAsync(instaImage, thread.ThreadId, uploadId, progress); }
private async Task UploadPhotoAsync(string caption, string imageURI) { WebClient webClient = new WebClient(); webClient.DownloadFile(imageURI, @"c:\test.jpg"); var mediaImage = new InstaImage { Height = 1080, Width = 1080, URI = new Uri(Path.GetFullPath(@"c:\test.jpg"), UriKind.Absolute).LocalPath }; await _api.UploadPhotoAsync(mediaImage, caption); Console.WriteLine("Photo posted!"); }
public async void UploadImage() { Assert.True(_authInfo.ApiInstance.IsUserAuthenticated); var mediaImage = new InstaImage { Height = 1080, Width = 1080, URI = new Uri(@"D:\Dropbox\Public\Inspire.jpg", UriKind.Absolute).LocalPath }; var result = await _authInfo.ApiInstance.UploadPhotoAsync(mediaImage, "inspire"); //assert Assert.True(result.Succeeded); Assert.NotNull(result.Value); }
public async void UploadVideo() { Assert.True(_authInfo.ApiInstance.IsUserAuthenticated); var mediaVideo = new InstaVideo(Path.GetFullPath(@"../../../../assets/video.mp4"), 640, 480, 3); var mediaImage = new InstaImage { Height = 480, Width = 640, URI = new Uri(Path.GetFullPath(@"../../../../assets/video_image.jpg"), UriKind.Absolute).LocalPath }; var result = await _authInfo.ApiInstance.UploadVideoAsync(mediaVideo, mediaImage, "mountains"); //assert Assert.True(result.Succeeded); Assert.NotNull(result.Value); }
private async void btnSendImage_Click(object sender, EventArgs e) { OpenFileDialog op = new OpenFileDialog(); op.Title = "تصویر را انتخاب کنید "; op.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"; grpStory.Visible = false; lblStory.Visible = true; progressBar1.Visible = true; for (int i = 0; i < 100; i++) { progressBar1.percentage = i; } timeLoad.Enabled = true; if (op.ShowDialog() == DialogResult.OK) { var image = new InstaImage() { Uri = op.FileName, }; var res = await ApiManage.instaApi.StoryProcessor.UploadStoryPhotoAsync(image, txtCaption.Text); if (res.Succeeded) { MessageBox.Show("عکس با موفقیت آپلود شد "); grpStory.Visible = true; lblStory.Visible = false; progressBar1.Percentage = 100; progressBar1.Visible = false; } else { MessageBox.Show($"آپلود انجام نشد به دلیل \n {res.Info.Message}"); grpStory.Visible = true; lblStory.Visible = false; progressBar1.Percentage = 100; progressBar1.Visible = false; } } }
private async Task <string> DownloadImage(InstaMedia item, InstaImage image) { var request = WebRequest.Create(image.Uri); var fileName = Path.Combine(fileLocation, $"{item.Identifier}.jpg"); using (WebResponse response = await request.GetResponseAsync().ConfigureAwait(false)) { using (Stream stream = response.GetResponseStream()) { using (FileStream streamWriter = File.Create(fileName)) { await stream.CopyToAsync(streamWriter).ConfigureAwait(false); } } } return(fileName); }
private async void UploadButtonClick(object sender, RoutedEventArgs e) { var uploader = new StoryPhotoUploaderHelper(); Helper.ShowNotify("We will notify you once your photo story uploaded...", 3000); var fileBytes = (await FileIO.ReadBufferAsync(FileToUpload)).ToArray(); var img = new InstaImage { ImageBytes = fileBytes }; uploader.UploadSinglePhoto(FileToUpload, ""); MainPage.Current?.ShowMediaUploadingUc(); if (NavigationService.Frame.CanGoBack) { NavigationService.GoBack(); } }
public async Task DoShow() { var images = new InstaImage[] { new InstaImage { // leave zero, if you don't know how height and width is it. Height = 0, Width = 0, Uri = @"c:\image1.jpg" }, new InstaImage { // leave zero, if you don't know how height and width is it. Height = 0, Width = 0, Uri = @"c:\image2.jpg" } }; var videos = new InstaVideoUpload[] { new InstaVideoUpload { // leave zero, if you don't know how height and width is it. Video = new InstaVideo(@"c:\video1.mp4", 0, 0), VideoThumbnail = new InstaImage(@"c:\video thumbnail 1.jpg", 0, 0) }, new InstaVideoUpload { // leave zero, if you don't know how height and width is it. Video = new InstaVideo(@"c:\video2.mp4", 0, 0), VideoThumbnail = new InstaImage(@"c:\video thumbnail 2.jpg", 0, 0) } }; var result = await _instaApi.MediaProcessor.UploadAlbumAsync(images, videos, "Hey, this my first album upload via InstagramApiSharp library."); Console.WriteLine(result.Succeeded ? $"Media created: {result.Value.Pk}, {result.Value.Caption}" : $"Unable to upload photo: {result.Info.Message}"); }
private async Task <IResult <bool> > UploadVideoThumbnailAsync(InstaImage image, string uploadId) { try { var instaUri = UriCreator.GetUploadPhotoUri(); var requestContent = new MultipartFormDataContent(uploadId) { { new StringContent(uploadId), "\"upload_id\"" }, { new StringContent(_deviceInfo.DeviceGuid.ToString()), "\"_uuid\"" }, { new StringContent(_user.CsrfToken), "\"_csrftoken\"" }, { new StringContent("{\"lib_name\":\"jt\",\"lib_version\":\"1.3.0\",\"quality\":\"87\"}"), "\"image_compression\"" } }; var imageContent = new ByteArrayContent(File.ReadAllBytes(image.URI)); imageContent.Headers.Add("Content-Transfer-Encoding", "binary"); imageContent.Headers.Add("Content-Type", "application/octet-stream"); requestContent.Add(imageContent, "photo", $"pending_media_{uploadId}.jpg"); var request = HttpHelper.GetDefaultRequest(HttpMethod.Post, instaUri, _deviceInfo); request.Content = requestContent; var response = await _httpRequestProcessor.SendAsync(request); var json = await response.Content.ReadAsStringAsync(); var imgResp = JsonConvert.DeserializeObject <ImageThumbnailResponse>(json); if (imgResp.Status.ToLower() == "ok") { return(Result.Success(true)); } else { return(Result.Fail <bool>("Could not upload thumbnail")); } } catch (Exception exception) { _logger?.LogException(exception); return(Result.Fail <bool>(exception)); } }
public static bool UploadPicture(string path, string caption) { InstaImageUpload img = new InstaImageUpload() { Uri = path }; InstaImage img2 = new InstaImage() { Uri = path }; var iimg = _api.MediaProcessor.UploadPhotoAsync(img, caption).Result; var anotherResult = _api.StoryProcessor.UploadStoryPhotoAsync(img2, caption).Result; //System.Threading.Thread.Sleep(1000); InstaMedia im = iimg.Value; File.Delete(path); Console.WriteLine("New Image online"); return(true); }
public async Task UploadPhotoAsync(Post post) { Image image = post.Images.First(); if (image != null) { var mediaImage = new InstaImage { Height = 1080, Width = 1080, URI = new Uri(Path.GetFullPath(image.PathResize), UriKind.Absolute).LocalPath, }; var result = await _instaApi.UploadPhotoAsync(mediaImage, post.Subtitle); post.IsPosted = result.Succeeded; } else { throw new Exception("O post não possui imagem associada!"); } }