Beispiel #1
0
        public async Task UseBitLy(string apkikey, string url)
        {
            var bitly        = new Bitly(apkikey);
            var linkResponse = await bitly.PostShorten(url);

            URL = linkResponse.Link;
        }
Beispiel #2
0
        public async Task <string> shortenUrl(string url)
        {
            var bitly        = new Bitly(_token);
            var linkResponse = await bitly.PostShorten(url);

            var newLink = linkResponse.Link;

            return(newLink);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        /* Создаёт сокращённую ссылку */
        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);
        }