VopSdk一個高逼格微信公衆號開發SDK:自動化生產(裝逼模式開啓)

VopSdk一個高逼格微信公衆號開發SDK(源碼下載)php

VopSdk一個高逼格微信公衆號開發SDK:自動化生產(裝逼模式開啓)html

 

針對初版,咱們搞了第二版本,老規矩先定個目標。web

一 咱們的目標json

    a、移除PayExcute,統一執行入口,目前只保留一個入口Excuteapi

    b、序列化特性統一,目前只用設置xml特性便可(反序列化時xml和json均可以直接用)服務器

    c、支持文件上傳,目前只有多客服管理上傳頭像接口用到過微信

    d、使用T4模板自動生產全部Request、Response、以及全部測試Test(裝逼利器T4模板)app

 

二 目標實現ide

    a、移除PayExcute,統一執行入口,目前只保留一個入口Excute測試

        public T Execute<T>(IVopRequest<T> request) where T : IVopResponse
        {
            return Execute<T>(request, null);
        }

        public T Execute<T>(IVopRequest<T> request, string accessToken) where T : IVopResponse
        {
            //設置請求參數值
            request.SetCharset(charset);
            request.SetAppId(appId);
            request.SetAppScret(appScret);
            request.SetMchId(mchId);
            request.SetMchScret(mchScret);
            request.SetSignType(signType);
            if (!string.IsNullOrEmpty(accessToken))
                request.SetAccessToken(accessToken);

            //初始參數
            string body;
            string url;
            url = request.GetApiUrl();

            //設置參數
            VopDictionary txtParams = request.GetParamter();
            txtParams = AddBizModel(txtParams, request.GetBizModel());

            //清洗url參數
            txtParams = FlashUrlParamter(txtParams, ref url);

            //添加簽名
            if (request.GetNeedSign())
                txtParams.Add("sign", VopUtils.GetSign(txtParams, request.GetMchScret()));

            //最後請求參數
            string data = null;
            IDictionary<string, FileItem> filedata = null;
            if (request is VopMobilePublicUploadRequest<T>)
            {
                filedata = GetRequestFileParams(txtParams);
            }
            else
            {
                data = GetRequestParams(txtParams, request.GetFormat());
            }

            if ("POST".Equals(request.GetApiMethod(), StringComparison.OrdinalIgnoreCase))
            {
                if (request is VopMobilePublicUploadRequest<T>)
                {
                    body = webUtils.DoPost(url, filedata, this.charset);
                }
                else
                {
                    if (!request.GetNeedCert())
                        body = webUtils.DoPost(url, data, this.charset);
                    else
                        body = webUtils.DoPost(url, data, this.charset, VopUtils.GetCert(request.GetCertPath(), request.GetCertPassword()));
                }
            }
            else
            {
                if (!request.GetNeedCert())
                    body = webUtils.DoGet(url, data, this.charset);
                else
                    body = webUtils.DoGet(url, data, this.charset, VopUtils.GetCert(request.GetCertPath(), request.GetCertPassword()));
            }

            T rsp = null;
            if ("json".Equals(request.GetFormat(), StringComparison.OrdinalIgnoreCase))
            {
                rsp = JsonHelper.Deserialize<T>(body);
            }
            else
            {
                rsp = XmlHelper.Deserialize<T>(body);
            }
            if (rsp != null)
                rsp.Body = body;
            return rsp;
        }

 

 

    b、序列化特性統一

         全部Response標記只用xml的特性標記,如 VopMobilePublicAccessTokenResponse 這個最後咱們其實序列化成json的,可是也是用的xml的來標記的。

    [XmlRoot("xml")]
    public class VopMobilePublicAccessTokenResponse : VopMobilePublicResponse
    {
        [XmlElement("access_token")]
        public string AccessToken { get; set; }
        [XmlElement("expires_in")]
        public int ExpiresIn { get; set; }
    }

 

 

 

    c、支持文件上傳

        文件上傳的接口Request須要繼承 VopMobilePublicUploadRequest ,在執行時,判斷若是繼承了,就會執行

                if (request is VopMobilePublicUploadRequest<T>)
                {
                    body = webUtils.DoPost(url, filedata, this.charset);
                }
        public string DoPost(string url, IDictionary<string, FileItem> fileParams, string charset)
        {
            string boundary = DateTime.Now.Ticks.ToString("X"); // 隨機分隔線

            HttpWebRequest req = GetWebRequest(url, "POST");
            req.ContentType = "multipart/form-data;charset=" + charset + ";boundary=" + boundary;

            Stream reqStream = req.GetRequestStream();
            byte[] itemBoundaryBytes = Encoding.GetEncoding(charset).GetBytes("\r\n--" + boundary + "\r\n");
            byte[] endBoundaryBytes = Encoding.GetEncoding(charset).GetBytes("\r\n--" + boundary + "--\r\n");

            // 組裝文件請求參數
            string fileTemplate = "Content-Disposition:form-data;name=\"{0}\";filename=\"{1}\"\r\nContent-Type:{2}\r\n\r\n";
            IEnumerator<KeyValuePair<string, FileItem>> fileEnum = fileParams.GetEnumerator();
            while (fileEnum.MoveNext())
            {
                string key = fileEnum.Current.Key;
                FileItem fileItem = fileEnum.Current.Value;
                string fileEntry = string.Format(fileTemplate, key, fileItem.GetFileName(), fileItem.GetMimeType());
                byte[] itemBytes = Encoding.GetEncoding(charset).GetBytes(fileEntry);
                reqStream.Write(itemBoundaryBytes, 0, itemBoundaryBytes.Length);
                reqStream.Write(itemBytes, 0, itemBytes.Length);

                byte[] fileBytes = fileItem.GetContent();
                reqStream.Write(fileBytes, 0, fileBytes.Length);
            }

            reqStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
            reqStream.Close();

            HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
            Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet);
            return GetResponseAsString(rsp, encoding);
        }

 

 

    d、使用T4模板自動生產全部Request、Response、以及全部測試Test(裝逼利器T4模板)

        廢話很少說,直接上其中一個模板 VopMobilePublicRequest.tt 

<#@ template  debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#@ Assembly Name="System.Core" #>
<#@ Assembly Name="System.Windows.Forms" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ include file="$(ProjectDir)VopConfig.ttinclude"  #>
<#@ include file="$(ProjectDir)Manager.ttinclude"  #>
<# var manager = Manager.Create(Host, GenerationEnvironment); #>
<# var list = TempService.Instance.GetListModel("Vop.config"); #>
<# foreach (var item in list){var model = item; manager.StartNewFile(model.Name + "Request.cs" );#>
//------------------------------------------------------------------------------
// <auto-generated>
//     此代碼由T4模板自動生成
//     生成時間 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#>
//     對此文件的更改可能會致使不正確的行爲,而且若是從新生成代碼,這些更改將會丟失
//     做者QQ:63351550 微信:VopSdk
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using Vop.Api.Response;

namespace Vop.Api.Request
{
    public class <#= model.Name #>Request : VopMobilePublicRequest<VopMobilePublicAccessTokenResponse>, IVopRequest<VopMobilePublicAccessTokenResponse>
    {
        public override string GetApiUrl()
        {
            this.apiUrl = "<#= model.Url #>";
            return PreApiUrl(this.apiUrl);
        }

        public override string GetApiMethod()
        {
            this.apiMethod = "<#= model.Method #>";
            return this.apiMethod;
        }
    }
}

<# manager.EndBlock();}#>
<# manager.Process(true); #>

 爲了裝個逼,我也是費了很多力氣的,首先得準備好各個接口名字、接口地址、接口調用方式,後期還得整理接口出參。

目前整理微信公衆號、微信支付全部接口,不行你看

 Vop.config 

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <apis>
    <!--微信網頁開發-->
    <api>
      <name>VopMobilePublicOAuthAuthorize</name>
      <url><![CDATA[https://open.weixin.qq.com/connect/oauth2/authorize?appid={appid}&redirect_uri={redirect_uri}&response_type=code&scope={scope}&state={state}#wechat_redirect]]></url>
      <method>GET</method>
      <desc>第一步:用戶贊成受權,獲取code</desc>
      <doc>https://mp.weixin.qq.com/wiki/4/9ac2e7b1f1d22e9e57260f6553822520.html</doc>
    </api>
    <api>
      <name>VopMobilePublicOAuthAccessToken</name>
      <url><![CDATA[https://api.weixin.qq.com/sns/oauth2/access_token?appid={appid}&secret={secret}&code={code}&grant_type=authorization_code]]></url>
      <method>GET</method>
      <desc>第二步:經過code換取網頁受權access_token</desc>
      <doc>https://mp.weixin.qq.com/wiki/4/9ac2e7b1f1d22e9e57260f6553822520.html</doc>
    </api>
    <api>
      <name>VopMobilePublicOAuthRefreshToken</name>
      <url><![CDATA[https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={appid}&grant_type=refresh_token&refresh_token={refresh_token}]]></url>
      <method>GET</method>
      <desc>第三步:刷新access_token(若是須要)</desc>
      <doc>https://mp.weixin.qq.com/wiki/4/9ac2e7b1f1d22e9e57260f6553822520.html</doc>
    </api>
    <api>
      <name>VopMobilePublicOAuthUserInfo</name>
      <url><![CDATA[https://api.weixin.qq.com/sns/userinfo?access_token={access_token}&openid={openid}&lang={lang}]]></url>
      <method>GET</method>
      <desc>第四步:拉取用戶信息(需scope爲 snsapi_userinfo)</desc>
      <doc>https://mp.weixin.qq.com/wiki/4/9ac2e7b1f1d22e9e57260f6553822520.html</doc>
    </api>
    <api>
      <name>VopMobilePublicOAuthAccessTokenCheck</name>
      <url><![CDATA[https://api.weixin.qq.com/sns/auth?access_token={access_token}&openid={openid}]]></url>
      <method>GET</method>
      <desc>附:檢驗受權憑證(access_token)是否有效</desc>
      <doc>https://mp.weixin.qq.com/wiki/4/9ac2e7b1f1d22e9e57260f6553822520.html</doc>
    </api>
    <!--開始開發-->
    <!--<api>
      <name>VopMobilePublicAccessToken</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appid}&secret={secret}]]></url>
      <method>GET</method>
      <desc>獲取access_token</desc>
      <doc>https://mp.weixin.qq.com/wiki/14/9f9c82c1af308e3b14ba9b973f99a8ba.html</doc>
    </api>-->
    <api>
      <name>VopMobilePublicServerIp</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>獲取微信服務器IP地址</desc>
      <doc>https://mp.weixin.qq.com/wiki/4/41ef0843d6e108cf6b5649480207561c.html</doc>
    </api>
    <!--自定義菜單-->
    <api>
      <name>VopMobilePublicMenuAdd</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/menu/create?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>自定義菜單建立接口</desc>
      <doc>https://mp.weixin.qq.com/wiki/10/0234e39a2025342c17a7d23595c6b40a.html</doc>
    </api>
    <api>
      <name>VopMobilePublicMenuGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/menu/get?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>自定義菜單查詢接口</desc>
      <doc>https://mp.weixin.qq.com/wiki/5/f287d1a5b78a35a8884326312ac3e4ed.html</doc>
    </api>
    <api>
      <name>VopMobilePublicMenuDel</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/menu/delete?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>自定義菜單刪除接口</desc>
      <doc>https://mp.weixin.qq.com/wiki/3/de21624f2d0d3dafde085dafaa226743.html</doc>
    </api>
    <api>
      <name>VopMobilePublicMenuConditionalAdd</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>建立個性化菜單</desc>
      <doc>https://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html</doc>
    </api>
    <api>
      <name>VopMobilePublicMenuConditionalDel</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>刪除個性化菜單</desc>
      <doc>https://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html</doc>
    </api>
    <api>
      <name>VopMobilePublicMenuConditionalGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>測試個性化菜單匹配結果</desc>
      <doc>https://mp.weixin.qq.com/wiki/0/c48ccd12b69ae023159b4bfaa7c39c20.html</doc>
    </api>
    <api>
      <name>VopMobilePublicMenuConfigGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取自定義菜單配置接口</desc>
      <doc>https://mp.weixin.qq.com/wiki/14/293d0cb8de95e916d1216a33fcb81fd6.html</doc>
    </api>
    <!--消息管理-->
    <api>
      <name>VopMobilePublicKfaccountAdd</name>
      <url><![CDATA[https://api.weixin.qq.com/customservice/kfaccount/add?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>添加客服賬號</desc>
      <doc>https://mp.weixin.qq.com/wiki/11/c88c270ae8935291626538f9c64bd123.html</doc>
    </api>
    <api>
      <name>VopMobilePublicKfaccountEdt</name>
      <url><![CDATA[https://api.weixin.qq.com/customservice/kfaccount/update?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>修改客服賬號</desc>
      <doc>https://mp.weixin.qq.com/wiki/11/c88c270ae8935291626538f9c64bd123.html</doc>
    </api>
    <api>
      <name>VopMobilePublicKfaccountDel</name>
      <url><![CDATA[https://api.weixin.qq.com/customservice/kfaccount/del?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>刪除客服賬號</desc>
      <doc>https://mp.weixin.qq.com/wiki/11/c88c270ae8935291626538f9c64bd123.html</doc>
    </api>
    <!--<api>
      <name>VopMobilePublicKfaccountUploadHeadImg</name>
      <url><![CDATA[http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token={access_token}&kf_account={kf_account}]]></url>
      <method>POST</method>
      <desc>設置客服賬號的頭像</desc>
      <doc>https://mp.weixin.qq.com/wiki/11/c88c270ae8935291626538f9c64bd123.html</doc>
    </api>-->
    <api>
      <name>VopMobilePublicKfaccountGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>獲取全部客服帳號</desc>
      <doc>https://mp.weixin.qq.com/wiki/11/c88c270ae8935291626538f9c64bd123.html</doc>
    </api>
    <api>
      <name>VopMobilePublicCustomMessageSend</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>客服接口-發消息</desc>
      <doc>https://mp.weixin.qq.com/wiki/11/c88c270ae8935291626538f9c64bd123.html</doc>
    </api>
    <api>
      <name>VopMobilePublicTemplateIndustrySet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>設置所屬行業</desc>
      <doc>https://mp.weixin.qq.com/wiki/5/6dde9eaa909f83354e0094dc3ad99e05.html</doc>
    </api>
    <api>
      <name>VopMobilePublicTemplateIndustryGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>獲取設置的行業信息</desc>
      <doc>https://mp.weixin.qq.com/wiki/5/6dde9eaa909f83354e0094dc3ad99e05.html</doc>
    </api>
    <api>
      <name>VopMobilePublicTemplatePrivateAdd</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>得到模板ID</desc>
      <doc>https://mp.weixin.qq.com/wiki/5/6dde9eaa909f83354e0094dc3ad99e05.html</doc>
    </api>
    <api>
      <name>VopMobilePublicTemplatePrivateGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>獲取模板列表</desc>
      <doc>https://mp.weixin.qq.com/wiki/5/6dde9eaa909f83354e0094dc3ad99e05.html</doc>
    </api>
    <api>
      <name>VopMobilePublicTemplatePrivateDel</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>刪除模板</desc>
      <doc>https://mp.weixin.qq.com/wiki/5/6dde9eaa909f83354e0094dc3ad99e05.html</doc>
    </api>
    <api>
      <name>VopMobilePublicTemplateMessageSend</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>發送模板消息</desc>
      <doc>https://mp.weixin.qq.com/wiki/5/6dde9eaa909f83354e0094dc3ad99e05.html</doc>
    </api>
    <!--用戶管理-->
    <api>
      <name>VopMobilePublicGroupsAdd</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/groups/create?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>建立分組</desc>
      <doc>https://mp.weixin.qq.com/wiki/8/d6d33cf60bce2a2e4fb10a21be9591b8.html</doc>
    </api>
    <api>
      <name>VopMobilePublicGroupsGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/groups/get?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>查詢全部分組</desc>
      <doc>https://mp.weixin.qq.com/wiki/8/d6d33cf60bce2a2e4fb10a21be9591b8.html</doc>
    </api>
    <api>
      <name>VopMobilePublicGroupsUserGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/groups/getid?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>查詢用戶所在分組</desc>
      <doc>https://mp.weixin.qq.com/wiki/8/d6d33cf60bce2a2e4fb10a21be9591b8.html</doc>
    </api>
    <api>
      <name>VopMobilePublicGroupsEdt</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/groups/update?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>修改分組名</desc>
      <doc>https://mp.weixin.qq.com/wiki/8/d6d33cf60bce2a2e4fb10a21be9591b8.html</doc>
    </api>
    <api>
      <name>VopMobilePublicGroupsUserEdt</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>移動用戶分組</desc>
      <doc>https://mp.weixin.qq.com/wiki/8/d6d33cf60bce2a2e4fb10a21be9591b8.html</doc>
    </api>
    <api>
      <name>VopMobilePublicGroupsUserBatchEdt</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/groups/members/batchupdate?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>批量移動用戶分組</desc>
      <doc>https://mp.weixin.qq.com/wiki/8/d6d33cf60bce2a2e4fb10a21be9591b8.html</doc>
    </api>
    <api>
      <name>VopMobilePublicGroupsDel</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/groups/delete?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>刪除分組</desc>
      <doc>https://mp.weixin.qq.com/wiki/8/d6d33cf60bce2a2e4fb10a21be9591b8.html</doc>
    </api>
    <api>
      <name>VopMobilePublicUserEdt</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token={access_token}]]></url>
      <method>GET</method>
      <desc>設置備註名</desc>
      <doc>https://mp.weixin.qq.com/wiki/16/528098c4a6a87b05120a7665c8db0460.html</doc>
    </api>
    <api>
      <name>VopMobilePublicUserGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/user/info?access_token={access_token}&openid={openid}&lang={lang}]]></url>
      <method>POST</method>
      <desc>獲取用戶基本信息(包括UnionID機制)</desc>
      <doc>https://mp.weixin.qq.com/wiki/1/8a5ce6257f1d3b2afb20f83e72b72ce9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicUserBatchGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>批量獲取用戶基本信息</desc>
      <doc>https://mp.weixin.qq.com/wiki/1/8a5ce6257f1d3b2afb20f83e72b72ce9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicUserListGet</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/user/get?access_token={access_token}&next_openid={next_openid}]]></url>
      <method>GET</method>
      <desc>獲取用戶列表</desc>
      <doc>https://mp.weixin.qq.com/wiki/12/54773ff6da7b8bdc95b7d2667d84b1d4.html</doc>
    </api>
    <!--帳號管理-->
    <api>
      <name>VopMobilePublicQrcode</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>建立二維碼ticket</desc>
      <doc>https://mp.weixin.qq.com/wiki/18/167e7d94df85d8389df6c94a7a8f78ba.html</doc>
    </api>
    <api>
      <name>VopMobilePublicShortUrl</name>
      <url><![CDATA[https://api.weixin.qq.com/cgi-bin/shorturl?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>長連接轉短連接接口</desc>
      <doc>https://mp.weixin.qq.com/wiki/6/856aaeb492026466277ea39233dc23ee.html</doc>
    </api>
    <!--數據統計-->
    <api>
      <name>VopMobilePublicDataCubeUserSummary</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getusersummary?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取用戶增減數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/15/88726a421bfc54654a3095821c3ca3bb.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUserCumulate</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getusercumulate?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取累計用戶數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/15/88726a421bfc54654a3095821c3ca3bb.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeArticleSummary</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getarticlesummary?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取圖文羣發每日數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/9/d347c6ddb6f86ab11ec3b41c2729c8d9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeArticleTotal</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getarticletotal?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取圖文羣發總數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/9/d347c6ddb6f86ab11ec3b41c2729c8d9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUserRead</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getuserread?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取圖文統計數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/9/d347c6ddb6f86ab11ec3b41c2729c8d9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUserReadHour</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getuserreadhour?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取圖文統計分時數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/9/d347c6ddb6f86ab11ec3b41c2729c8d9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUserShare</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getusershare?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取圖文分享轉發數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/9/d347c6ddb6f86ab11ec3b41c2729c8d9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUserShareHour</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getusersharehour?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取圖文分享轉發分時數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/9/d347c6ddb6f86ab11ec3b41c2729c8d9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUpStreamMsg</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getupstreammsg?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取消息發送概況數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/10/b29e8ca8bf1b0dce033ccb70273f90fa.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUpStreamMsgHour</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getupstreammsghour?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取消息分送分時數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/10/b29e8ca8bf1b0dce033ccb70273f90fa.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUpStreamMsgWeek</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getupstreammsgweek?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取消息發送週數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/10/b29e8ca8bf1b0dce033ccb70273f90fa.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUpStreamMsgMonth</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getupstreammsgmonth?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取消息發送月數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/10/b29e8ca8bf1b0dce033ccb70273f90fa.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUpStreamMsgDist</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getupstreammsgdist?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取消息發送分佈數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/10/b29e8ca8bf1b0dce033ccb70273f90fa.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUpStreamMsgDistWeek</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getupstreammsgdistweek?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取消息發送分佈週數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/10/b29e8ca8bf1b0dce033ccb70273f90fa.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeUpStreamMsgDistMonth</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getupstreammsgdistmonth?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取消息發送分佈月數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/10/b29e8ca8bf1b0dce033ccb70273f90fa.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeInterfaceSummary</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getinterfacesummary?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取消息發送分佈月數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/17/252a976f20bd3062af3f03a45f30cff9.html</doc>
    </api>
    <api>
      <name>VopMobilePublicDataCubeInterfaceSummaryHour</name>
      <url><![CDATA[https://api.weixin.qq.com/datacube/getinterfacesummaryhour?access_token={access_token}]]></url>
      <method>POST</method>
      <desc>獲取接口分析分時數據</desc>
      <doc>https://mp.weixin.qq.com/wiki/17/252a976f20bd3062af3f03a45f30cff9.html</doc>
    </api>
  </apis>
</configuration>

 VopTrade.config 

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <apis>
    <!--微信支付-->
    <api>
      <name>VopTradeUnifiedOrder</name>
      <url><![CDATA[https://api.mch.weixin.qq.com/pay/unifiedorder]]></url>
      <method>POST</method>
      <desc>統一下單</desc>
      <doc>https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1</doc>
    </api>
    <api>
      <name>VopTradeOrderQuery</name>
      <url><![CDATA[https://api.mch.weixin.qq.com/pay/orderquery]]></url>
      <method>POST</method>
      <desc>查詢訂單</desc>
      <doc>https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2</doc>
    </api>
    <api>
      <name>VopTradeCloseOrder</name>
      <url><![CDATA[https://api.mch.weixin.qq.com/pay/closeorder]]></url>
      <method>POST</method>
      <desc>關閉訂單</desc>
      <doc>https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3</doc>
    </api>
    <api>
      <name>VopTradeRefund</name>
      <url><![CDATA[https://api.mch.weixin.qq.com/secapi/pay/refund]]></url>
      <method>POST</method>
      <desc>申請退款</desc>
      <doc>https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4</doc>
    </api>
    <api>
      <name>VopTradeRefundQuery</name>
      <url><![CDATA[https://api.mch.weixin.qq.com/pay/refundquery]]></url>
      <method>POST</method>
      <desc>查詢退款</desc>
      <doc>https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5</doc>
    </api>
    <api>
      <name>VopTradeDownloadBill</name>
      <url><![CDATA[https://api.mch.weixin.qq.com/pay/downloadbill]]></url>
      <method>POST</method>
      <desc>下載對帳單</desc>
      <doc>https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_6</doc>
    </api>
  </apis>
</configuration>

 

有了這兩個配置文件,T4模板引擎就能夠開工了,只需讀取配置文件,一個一個cs給我生產就好了啊,哈哈哈哈

只需保存下T4模板就可生產全部cs文件了,不信你看

 

 

 

 

 

原文地址:http://www.cnblogs.com/deeround/p/6847671.html 

源碼下載:

相關文章
相關標籤/搜索