zoukankan      html  css  js  c++  java
  • C#生成新浪微博短网址 示例源码

    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("http://api.t.sina.com.cn/short_url/shorten.json?source=1681459862&url_long="   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 { getset; }
       
            /// <summary>
            /// 长域名
            /// </summary>
            public virtual string url_long { getset; }
       
            /// <summary>
            /// 类型
            /// </summary>
            public virtual int type { getset; }
        }
     
     
    }
  • 相关阅读:
    PHP preg_replace_callback_array() 函数
    PHP preg_quote() 函数
    PHP preg_match() 函数
    SqlHelper工具类
    ArrayListd的长度问题
    事务
    Socket通信
    时间戳,产生随机数
    背景大小 | background-size (Backgrounds & Borders)
    背景图片位置 | background-position (Backgrounds & Borders)
  • 原文地址:https://www.cnblogs.com/hclw/p/5995908.html
Copyright © 2011-2022 走看看