using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
DotNetSample.Models;
using
System.Web.Script.Serialization;
namespace
DotNetSample.Utils
{
public
class
ShortUrlHelper
{
/// <summary>
/// 获取新浪短域名
/// </summary>
/// <param name="url">原始地址</param>
/// <returns></returns>
public
static
ShortUrl SinaShortUrl(
string
url)
{
string
builder = HtmlEncode.GetUrlHtml(
""
System.Web.HttpContext.Current.Server.UrlEncode(url)).Replace(
"["
,
""
).Replace(
"]"
,
""
);
return
new
JavaScriptSerializer().Deserialize<ShortUrl>(builder);
}
}
[Serializable]
public
class
ShortUrl
{
/// <summary>
/// 短域名
/// </summary>
public
virtual
string
url_short {
get
;
set
; }
/// <summary>
/// 长域名
/// </summary>
public
virtual
string
url_long {
get
;
set
; }
/// <summary>
/// 类型
/// </summary>
public
virtual
int
type {
get
;
set
; }
}
}