Using tinyurl.com in a .Net application … possible?

后端 未结 6 893
栀梦
栀梦 2020-12-28 08:24

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

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

This will automatically crea

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-28 09:13

    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);
    

提交回复
热议问题