每隔30分钟调用api并更新数据库

时间:2014-11-19 01:29:33

标签: c# asp.net sql-server-2008

我必须每隔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`
    }
}

0 个答案:

没有答案