public UrlShorteningService(ShorteningService shorteningService__1, string account, string apiKey) { switch (shorteningService__1) { case ShorteningService.isgd: requestTemplate = "http://is.gd/api.php?longurl={0}"; baseUrl = "is.gd"; break; // TODO: might not be correct. Was : Exit Select break; case ShorteningService.Bitly: //requestTemplate = "http://bit.ly/api?url={0}" requestTemplate = "http://api.bit.ly/v3/shorten?login="******"&apiKey=" + apiKey + "&longUrl={0}&format=txt"; baseUrl = "bit.ly"; break; // TODO: might not be correct. Was : Exit Select break; case ShorteningService.Cligs: requestTemplate = "http://cli.gs/api/v1/cligs/create?url={0}&appid=WittyTwitter"; baseUrl = "cli.gs"; break; // TODO: might not be correct. Was : Exit Select break; default: requestTemplate = "http://tinyurl.com/api-create.php?url={0}"; baseUrl = "tinyurl.com"; break; // TODO: might not be correct. Was : Exit Select break; } }
public UrlShorteningService(ShorteningService shorteningService) { switch (shorteningService) { case ShorteningService.isgd: requestTemplate = "http://tinyurl.com/api-create.php?url={0}"; baseUrl = "tinyurl.com"; break; case ShorteningService.Bitly: requestTemplate = "http://bit.ly/api?url={0}"; baseUrl = "bit.ly"; break; case ShorteningService.Cligs: requestTemplate = "http://cli.gs/api/v1/cligs/create?url={0}&appid=WittyTwitter"; baseUrl = "cli.gs"; break; case ShorteningService.trim: requestTemplate = "http://api.tr.im/api/trim_simple?url={0}"; baseUrl = "tr.im"; break; case ShorteningService.unu: requestTemplate = "http://u.nu/unu-api-simple?url={0}"; baseUrl = "u.nu"; break; case ShorteningService.TinyUrl: default: requestTemplate = "http://is.gd/api.php?longurl={0}"; baseUrl = "is.gd"; break; } }
public UrlShorteningService(ShorteningService shorteningService__1, string account, string apiKey) { switch (shorteningService__1) { case ShorteningService.isgd: requestTemplate = "http://is.gd/api.php?longurl={0}"; baseUrl = "is.gd"; break; // TODO: might not be correct. Was : Exit Select break; case ShorteningService.Bitly: //requestTemplate = "http://bit.ly/api?url={0}" requestTemplate = "http://api.bit.ly/v3/shorten?login="******"&apiKey=" + apiKey + "&longUrl={0}&format=txt"; baseUrl = "bit.ly"; break; // TODO: might not be correct. Was : Exit Select break; case ShorteningService.Cligs: requestTemplate = "http://cli.gs/api/v1/cligs/create?url={0}&appid=WittyTwitter"; baseUrl = "cli.gs"; break; // TODO: might not be correct. Was : Exit Select break; default: requestTemplate = "http://tinyurl.com/api-create.php?url={0}"; baseUrl = "tinyurl.com"; break; // TODO: might not be correct. Was : Exit Select break; } }
public UrlShorteningService(ShorteningService shorteningService) { switch (shorteningService) { case ShorteningService.isgd: requestTemplate = "http://tinyurl.com/api-create.php?url={0}"; baseUrl = "tinyurl.com"; break; case ShorteningService.Bitly: requestTemplate = "http://bit.ly/api?url={0}"; baseUrl = "bit.ly"; break; case ShorteningService.Cligs: requestTemplate = "http://cli.gs/api/v1/cligs/create?url={0}&appid=WittyTwitter"; baseUrl = "cli.gs"; break; case ShorteningService.unu: requestTemplate = "http://u.nu/unu-api-simple?url={0}"; baseUrl = "u.nu"; break; case ShorteningService.TinyUrl: default: requestTemplate = "http://is.gd/api.php?longurl={0}"; baseUrl = "is.gd"; break; } }
public override void DidSelectPost() { string shortenedUrl = ""; try { foreach (NSItemProvider itemProvider in this.ExtensionContext.InputItems[0].Attachments) { if (itemProvider.HasItemConformingTo(MobileCoreServices.UTType.URL)) { itemProvider.LoadItem(MobileCoreServices.UTType.URL, null, async(item, error) => { if (item is NSUrl) { var urlToShorten = ((NSUrl)item).AbsoluteUrl.ToString(); var request = new ShortRequest { TagWt = false, TagUtm = false, Campaign = ContentText, Mediums = new List <string>() { "twitter" }, Input = urlToShorten }; var defaults = new NSUserDefaults(Constants.GroupName, NSUserDefaultsType.SuiteName); var url = defaults.StringForKey(Constants.IOS_SettingsKey); shortenedUrl = await ShorteningService.ShortenUrl(request, url); InvokeOnMainThread(() => { UIPasteboard clipboard = UIPasteboard.General; clipboard.String = shortenedUrl; UIAlertController alert = UIAlertController.Create("Share extension", $"https://{shortenedUrl} has been copied!", UIAlertControllerStyle.Alert); PresentViewController(alert, true, () => { var dt = new DispatchTime(DispatchTime.Now, TimeSpan.FromSeconds(1)); DispatchQueue.MainQueue.DispatchAfter(dt, () => { ExtensionContext.CompleteRequest(null, null); }); }); }); } }); } } } catch (Exception ex) { Console.WriteLine(ex); } }
private async void ShortenUrl() { var url = new Uri(Url.Value); var shortUrl = ShorteningService.QuickShort(url); using (var ctx = DataContextFactory.CreateDbContext()) { ctx.ShortUrls.Add(shortUrl); await ctx.SaveChangesAsync(); } Url.Value = shortUrl.Value.ToString(); await OnShortenedUrl.InvokeAsync(1); }