VopSdk一個高逼格微信公眾號開發SDK(源碼下載) VopSdk一個高逼格微信公眾號開發SDK:自動化生產(裝逼模式開啟) 針對第一版,我們搞了第二版本,老規矩先定個目標。 一 我們的目標 a、移除PayExcute,統一執行入口,目前只保留一個入口Excute b、序列化特性統一,目前只用設置 ...
針對第一版,我們搞了第二版本,老規矩先定個目標。
一 我們的目標
a、移除PayExcute,統一執行入口,目前只保留一個入口Excute
b、序列化特性統一,目前只用設置xml特性即可(反序列化時xml和json都可以直接用)
c、支持文件上傳,目前只有多客服管理上傳頭像介面用到過
d、使用T4模板自動生產所有Request、Response、以及所有測試Test(裝逼利器T4模板)
二 目標實現
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
源碼下載: