码迷,mamicode.com
首页 > 其他好文 > 详细

百度短链接

时间:2016-04-13 12:43:17      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:

public string GetDwz(string Url)
{
Url = HttpUtility.UrlEncode(Url);
var data = "url=" + Url;
var url = "http://dwz.cn/create.php";
var client = new System.Net.WebClient();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
var rs = client.UploadString(url, "POST", data);
var urlParam = HttpUtility.UrlDecode(rs);
Console.WriteLine(rs);
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(urlParam);
object value;
json.TryGetValue("tinyurl", out value);
value = value == null ? json["longurl"] : value;
return value.ToString();
}

百度短链接

标签:

原文地址:http://www.cnblogs.com/l36i90u/p/5386451.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!