public void DownloadTest() { UploadTest(); var a = new AccessToken("wxe621f4e5e90b13cd", "7cb56e5b6bd302ddb73c4f76a9ec26a2"); var m = new MediaManager(a); m.Download(mediaId, "C:/1.jpg"); }
public void GetUserInfo() { var a = new AccessToken("wxe621f4e5e90b13cd", "7cb56e5b6bd302ddb73c4f76a9ec26a2"); var m = new UserManager(a); var userInfo = m.GetUserInfo("o4mqUjspXEinqvno9XS3RUGEITS8"); Assert.IsNotNull(userInfo); Console.WriteLine(userInfo.NickName); }
public void GenerateSquareCode() { var accessToken = new AccessToken("wxe621f4e5e90b13cd", "7cb56e5b6bd302ddb73c4f76a9ec26a2"); var s = new PromoteService(accessToken); var ticket = s.GenerateSquareCode(1); Assert.IsNotNull(ticket); Console.WriteLine(ticket); Console.WriteLine(System.Web.HttpUtility.UrlEncode(ticket)); }
public void UploadTest() { var a = new AccessToken("wx52544b324318b38d", "a8b7e285bbae296f8bbb77e0bf518b1b"); var m = new MediaManager(a); var mediaId = m.Upload(@"C:\Users\maishu\Pictures\100.jpg", MediaType.Image); Assert.IsNotNull(mediaId); Console.WriteLine(mediaId); this.mediaId = mediaId; }
public void GetJsapiTicket() { //Id URL Token AppId AppSecret ApplicationId CreateDateTime IsHide IsDelete Remark AppKey PartnerId PartnerKey //wxa22b9cfd8fdec01a d383a6032a4cef3dc22ba9c5130b60e2 7BBFA36C-8115-47AD-8D47-9E52B58E7EFD 2014-06-25 15:46:19.643 0 0 NULL IUInS0W9rSnhRsF1AC1YZx9TVX5elH2bbRV4wbcEMN8ykdz4r7ht3jyOjqiYYqZcNi1SIig7EVKckcl6eIQs0GdH6BmmbRo5dElL5e9cinlmbnbXhClKbItAAfE0wuCY 1220064601 a09d39a068eda7245dbc8de29e4f2ba5 //var a = new AccessToken("wxe621f4e5e90b13cd", "7cb56e5b6bd302ddb73c4f76a9ec26a2"); var a = new AccessToken("wxa22b9cfd8fdec01a", "d383a6032a4cef3dc22ba9c5130b60e2"); var t = new TicketGenerator(a); var js_ticket = t.GetJsapiTicket(); var s = new YuChang.Core.PromoteService(a); for (var i = 10842; i <= 10841 + 20; i++) { var str = s.GenerateSquareCode(i); Console.WriteLine(str); } //Assert.IsNotNull(js_ticket); //Console.WriteLine(js_ticket); }
public void SendTest() { // var appid = "wxa22b9cfd8fdec01a"; //var secret = "d383a6032a4cef3dc22ba9c5130b60e2"; var accessToken = new AccessToken("wxa22b9cfd8fdec01a", "d383a6032a4cef3dc22ba9c5130b60e2"); //var accessToken = new AccessToken("wxe621f4e5e90b13cd", "7cb56e5b6bd302ddb73c4f76a9ec26a2"); //vknew //var tmp = new Template("USLehg7XUyraVd2-FevC9NuTvzcCdTdbSnqTOamiZjE", "o1Ux1uGtRiummfXjhZ7vyIqNlzTU"); var tmp = new Template("USLehg7XUyraVd2-FevC9NuTvzcCdTdbSnqTOamiZjE", "o1Ux1uGtRiummfXjhZ7vyIqNlzTU"); tmp.Fields.Add(new TemplateField("first", "您好,你的商品已发货")); tmp.Fields.Add(new TemplateField("keyword1", "申通快递")); tmp.Fields.Add(new TemplateField("keyword2", "1111111111")); tmp.Fields.Add(new TemplateField("keyword3", "多个商品")); tmp.Fields.Add(new TemplateField("keyword4", "5")); tmp.Fields.Add(new TemplateField("remark", "请注意查收。")); var m = new TemplateManager(accessToken); m.Send(tmp); }
public static AccessToken GetAccessToken(string appid, string secret) { List<AccessToken> accessTokens; if (dic_accessTokens.TryGetValue(appid, out accessTokens) == false) { dic_accessTokens[appid] = accessTokens = new List<AccessToken>(); } string old_secret; if (secrets.TryGetValue(appid, out old_secret) == false) { secrets[appid] = old_secret = secret; } if (old_secret != secret) dic_accessTokens[appid] = new List<AccessToken>(); AccessToken result; for (int i = 0; i < accessTokens.Count; i++) { if (!accessTokens[i].IsUsing) { result = accessTokens[i]; return result; } } //if (string.IsNullOrEmpty(AccessTokenPool.AppId)) //{ // throw Error.AppIdIsRequired(); //} //if (string.IsNullOrEmpty(AccessTokenPool.AppSecret)) //{ // throw Error.AppSecretRequired(); //} AccessToken accessToken = new AccessToken(appid, secret); accessTokens.Add(accessToken); result = accessToken; return result; }
public ShoppingManager(AccessToken accessToken, string appKey) { this.accessToken = accessToken; this.appKey = appKey; }
public CustomMenu(AccessToken accessToken) { this.accessToken = accessToken; }
public PromoteService(AccessToken accessToken) { this.accessToken = accessToken; }
public TemplateManager(AccessToken accessToken) { this.accessToken = accessToken; }
public static void delete(AccessToken token) { var url = "menu/delete?access_token=" + token; weixin.Call(url, new { errcode = "" }); }
public static void create(AccessToken token, Button[] button) { var url = string.Format("menu/create?access_token={0}", token); weixin.Call(url, new { errcode = "" }, new { button }); }
public static void api_set_industry(AccessToken token, string industry_id1, string industry_id2) { var url = "template/api_set_industry?access_token=" + token; Call(url, new { errcode = "" }, new { industry_id1, industry_id2 }); }
public void ToString() { var accessToken = new AccessToken("wxe621f4e5e90b13cd", "7cb56e5b6bd302ddb73c4f76a9ec26a2"); var token = accessToken.ToString(); Assert.IsNotNull(token); }
public static getticket_result getticket(AccessToken token, TicketType type) { var url = "ticket/getticket?type=" + type.ToString() + "&access_token=" + token; return(Call(url, new getticket_result())); }
/// <summary> /// 删除群发【订阅号与服务号认证后均可用】 /// </summary> /// <param name="msg_Id"></param> public static void delete(AccessToken token, string msg_Id) { var url = "message/mass/send?access_token=" + token; Call(url, new { errorcode = "", errmsg = "" }); }
/// <summary> /// 根据OpenID列表群发【订阅号不可用,服务号认证后可用】 /// </summary> public static string send(AccessToken token, string mediaIdOrContent, MessageType msgtype, string[] touser) { if (string.IsNullOrEmpty(mediaIdOrContent)) { throw Error.ArugmentNull("mediaIdOrContent"); } if (touser == null) { throw Error.ArugmentNull("touser"); } if (touser.Length == 0) { var msg = "Length of the touser argument cannt be zero."; throw Error.ArugmentError(msg); } object obj; switch (msgtype) { case MessageType.mpnews: obj = new { touser, mpnews = new { media_id = mediaIdOrContent }, msgtype }; break; case MessageType.text: obj = new { touser, text = new { content = mediaIdOrContent }, msgtype }; break; case MessageType.voice: obj = new { touser, voice = new { media_id = mediaIdOrContent }, msgtype }; break; case MessageType.image: obj = new { touser, image = new { media_id = mediaIdOrContent }, msgtype }; break; default: var msg = string.Format("'{0}' is a unknown media type", msgtype); throw Error.ArugmentNull(msg); } var serial = new System.Web.Script.Serialization.JavaScriptSerializer(); var data = serial.Serialize(obj); var url = "message/mass/send?access_token=" + token; var json = weixin.GetJson(url, data); var dic = weixin.Deserialize(json, new { msg_id = "" }); return((string)dic.msg_id); }
/// <summary> /// 根据分组进行群发【订阅号与服务号认证后均可用】 /// </summary> public static string sendall(AccessToken token, string mediaIdOrContent, MessageType msgtype, string group_id) { object filter; if (!string.IsNullOrEmpty(group_id)) { filter = new { is_to_all = false, group_id }; } else { filter = new { is_to_all = true }; } object obj; switch (msgtype) { case MessageType.mpnews: obj = new { filter, mpnews = new { media_id = mediaIdOrContent }, msgtype }; break; case MessageType.text: obj = new { filter, text = new { content = mediaIdOrContent }, msgtype }; break; case MessageType.voice: obj = new { filter, voice = new { media_id = mediaIdOrContent }, msgtype }; break; case MessageType.image: obj = new { filter, image = new { media_id = mediaIdOrContent }, msgtype }; break; default: var msg = string.Format("'{0}' is a unknown media type", msgtype); throw Error.ArugmentNull(msg); } var serial = new System.Web.Script.Serialization.JavaScriptSerializer(); var data = serial.Serialize(obj); var url = "message/mass/sendall?access_token=" + token; var json = weixin.GetJson(url, data); var dic = weixin.Deserialize(json, new { msg_id = "" }); return(dic.msg_id); }
public MediaManager(AccessToken accessToken) { this.accessToken = accessToken; }
public MessageProcesser(string appid, string secret, IDbConnection conn) { this.accessToken = AccessTokenPool.GetAccessToken(appid, secret); //new AccessToken(appid, secret); this.conn = conn; }