public QueryWxUserCardResponse QueryWxUserMCards( IWxApp app, IWxUserOpenId wxuser, IWxMCardId mcard = null) { var url = string.Format("https://api.weixin.qq.com/card/user/getcardlist?access_token={0}" , GetToken(app.AppId, app.Secret)); return(url.GetUriJsonContent <QueryWxUserCardResponse>((http) => { http.Method = "POST"; http.ContentType = "application/json; encoding=utf-8"; var data = new { openid = wxuser.OpenId, card_id = (mcard == null || string.IsNullOrWhiteSpace(mcard.CardId)) ? null : mcard.CardId }; using (var stream = http.GetRequestStream()) { var body = data.SerializeToJson(); var buffers = UTF8Encoding.UTF8.GetBytes(body); stream.Write(buffers, 0, buffers.Length); stream.Flush(); } return http; })); }
public NormalWxResponse DeleteCardCoupon(IWxApp official, IWxMCardId cardId) { var url = string.Format("https://api.weixin.qq.com/card/delete?access_token={0}", GetToken(official.AppId, official.Secret)); return(url.GetUriJsonContent <NormalWxResponse>((http) => { var data = new { card_id = cardId.CardId }; http.Method = "POST"; http.ContentType = "application/json; encoding=utf-8"; using (var stream = http.GetRequestStream()) { var body = data.SerializeToJson(); var buffers = UTF8Encoding.UTF8.GetBytes(body); stream.Write(buffers, 0, buffers.Length); stream.Flush(); } return http; })); }