在.NET应用程序中使用tinyurl.com ......可能吗?应用程序、NET、com、tinyurl

由网友(我很怪i)分享简介:我发现下面的code创建一个tinyurl.com网址:I found the following code to create a tinyurl.com url:http://tinyurl.com/api-create.php?url=http://myurl.com这将自动创建一个TinyURL的URL。有...

我发现下面的code创建一个tinyurl.com网址:

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

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

这将自动创建一个TinyURL的URL。有没有办法做到这一点使用code,特别是C#在ASP.NET?

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);
阅读全文

相关推荐

最新文章