public async Task UseBitLy(string apkikey, string url) { var bitly = new Bitly(apkikey); var linkResponse = await bitly.PostShorten(url); URL = linkResponse.Link; }
public async Task <string> shortenUrl(string url) { var bitly = new Bitly(_token); var linkResponse = await bitly.PostShorten(url); var newLink = linkResponse.Link; return(newLink); }
public async Task PostShorten() { var bitly = new Bitly(_genericAccessToken); Assert.IsNotNull(bitly); var linkResponse = await bitly.PostShorten("https://www.google.ca/"); Assert.AreEqual("https://s.phansoft.ca/1WuTssO", linkResponse.Link); Assert.AreEqual("https://www.google.ca/", linkResponse.LongUrl); }
public async Task GetBitlinksByGroupRecent() { var bitly = new Bitly(_genericAccessToken); Assert.IsNotNull(bitly); var now = DateTime.Now; var testUrl = "https://www.google.ca/?q=" + now.ToShortDateString() + now.ToLongTimeString(); var linkResponse = await bitly.PostShorten(testUrl); //Bitly won't show links that are very new Thread.Sleep(new TimeSpan(0, 0, 0, 30)); var newest = await bitly.GetBitlinksByGroup(createdAfter : now); Assert.IsTrue(newest.Links.Any(l => l.LongUrl == testUrl)); }
/* Создаёт сокращённую ссылку */ private static string GetShortLink(string lpLongUrl, string lpKey) { var lpShortUrl = ""; try { var bitly = new Bitly(lpKey); var linkResponse = bitly.PostShorten(lpLongUrl); lpShortUrl = linkResponse.Result.Link; } catch { lpShortUrl = "error"; } return(lpShortUrl); }