/// <summary> /// Creates a captioned image given a memetype and sets of text /// </summary> /// <param name="memeID">The Id of the meme you want to caption</param> /// <param name="username">The username of the api account. You can register at http://www.imgflip.com</param> /// <param name="password">The password for the api account</param> /// <param name="TopText">Text on the top line of the meme</param> /// <param name="BottomText">Text on the bottom line of the meme</param> /// <returns></returns> public async Task <CaptionMemeRoot> CaptionMemeAsync(int memeID, String username, String password, String TopText, String BottomText) { String templateIDToUse = memeID.ToString(); CaptionMemeRoot x = await CaptionMemeAsync(templateIDToUse, username, password, TopText, BottomText); return(x); }
/// <summary> /// Updates the title or description of an image. You can only update an image you own and is associated with your account. For an anonymous image, {id} must be the image's deletehash. /// </summary> /// <param name="deleteHashOrImageID">The deletehash or ID of an image (ID ONLY WORKS IF LOGGED IN!)</param> /// <param name="Title">The title of the image.</param> /// <param name="Description">The description of the image.</param> /// <returns></returns> public async Task <CaptionMemeRoot> CaptionMemeAsync(String TemplateID, String username, String password, String TopText, String BottomText) { MultipartFormDataContent content = new MultipartFormDataContent(BoundaryGuid.ToString()); if (TemplateID != String.Empty) { content.Add(new StringContent(TemplateID), "template_id"); } if (username != String.Empty) { content.Add(new StringContent(username), "username"); } if (password != String.Empty) { // TODO: Handle password strings in a safer way content.Add(new StringContent(password), "password"); } if (TopText != null) { content.Add(new StringContent(TopText), "text0"); } if (BottomText != null) { content.Add(new StringContent(BottomText), "text1"); } String responseString = await PostAnonymousImgflipDataAsync(ImgFlipEndpoints.CaptionImage, content); CaptionMemeRoot x = await Task.Run(() => JsonConvert.DeserializeObject <CaptionMemeRoot>(responseString, _defaultSerializerSettings)); return(x); }
/// <summary> /// Returns an image url of the captioned image in markdown format /// </summary> /// <param name="memeType">an integer describing the memetype</param> /// <param name="TopText">The text on the top of the meme</param> /// <param name="BottomText">The text on the bottom of the meme</param> /// <returns></returns> public async static Task <Activity> GenerateResultForMemeCreate(int memeType, String TopText, String BottomText, Activity reply) { CaptionMemeRoot x = await ImgFlipAPISource.Instance.CaptionMemeAsync(memeType, Username, Password, TopText, BottomText); String imageUrl = x.data.url; Uri returnedImage = new Uri(imageUrl);; return(CreateResponseCardForMemeCreate(returnedImage, reply)); }
public void CaptionMeme() { string template_id = "0"; string toptext = "hello"; string bottomtext = "it's me"; GetMemeRoot x = ImgFlipAPISource.Instance.GetMemesAsync().Result; List<Meme> xList = x.data.memes; template_id = xList[0].id; CaptionMemeRoot z = ImgFlipAPISource.Instance.CaptionMemeAsync(template_id, username, password, toptext, bottomtext).Result; Assert.IsNotNull(z.data.url); }