我发现tinyurl api缩短了Url。你可以从下面的链接看到。
https://blogs.msdn.microsoft.com/bramveen/2009/01/06/converting-url-to-tinyurl-in-c/
我还希望从我缩短的网址中获取原始地址。
但我无法找到反向api。
有谁知道如何扭转它?
答案 0 :(得分:0)
看着api没有api可以反过来。但是,当您向微小网址发送HTTP请求时,所有tinyurl正在执行的操作是返回带有位于响应标头中的原始网址的HTTP 301。所以你可以这样做。
// Creates an HttpWebRequest for the specified URL.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
// Sends the HttpWebRequest and waits for response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
现在您可以使用响应对象来读取位置标头值(这是您的原始网址)。