我必须每隔30分钟为数据库中的每个字段调用一个api并更新相应字段中的响应
string Shorten(string url)
{
url = Uri.EscapeUriString(url);
string reqUri = String.Format(@"http://is.gd/api.php?longurl={0}", url);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(reqUri);
req.Timeout = 5000;
try
{
using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
{
return reader.ReadLine();
}
}
catch (WebException ex)
{
return ex.Message;`enter code here`
}
}