在 .Net 应用程序中使用 tinyurl.com ......可能吗? [英] Using tinyurl.com in a .Net application ... possible?

查看:31
本文介绍了在 .Net 应用程序中使用 tinyurl.com ......可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了以下代码来创建一个 tinyurl.com 网址:

I found the following code to create a tinyurl.com url:

http://tinyurl.com/api-create.php?url=http://myurl.com

这将自动创建一个 tinyurl 网址.有没有办法使用代码来做到这一点,特别是 ASP.NET 中的 C#?

This will automatically create a tinyurl url. Is there a way to do this using code, specifically C# in ASP.NET?

推荐答案

您可能应该添加一些错误检查等,但这可能是最简单的方法:

You should probably add some error checking, etc, but this is probably the easiest way to do it:

System.Uri address = new System.Uri("http://tinyurl.com/api-create.php?url=" + YOUR ADDRESS GOES HERE);
System.Net.WebClient client = new System.Net.WebClient();
string tinyUrl = client.DownloadString(address);
Console.WriteLine(tinyUrl);

这篇关于在 .Net 应用程序中使用 tinyurl.com ......可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆