//同步粉丝 public bool AsyncUser() { List <string> openidList = WXApi.GetOpenIDs(GetToken()); //获取关注者OpenID列表 foreach (var item in openidList) { WX_Fans fan = new WX_Fans(); fan.ConpanyID = UserDateTicket.Company.ID; fan.OPENID = item; WX_FansService.instance().Insert(fan); } return(true); }
protected void Button1_Click(object sender, EventArgs e) { //WXApi.DownloadMedia("http://localhost:2454/UploadFile/aa.png"); //Response.Write(WXApi.UploadMedia(Session["token"].ToString(), "image", "d:\\_临时文件\\aa.png")); //获取天气预报 //string result = HttpRequestUtil.RequestUrl("http://www.weather.com.cn/data/sk/101220101.html", "GET"); //Response.Write(result); //result = Weixin.Mp.Util.Tools.GetJosnValue(result, "WSE"); //Response.Write(result); //Response.Write(AdminUtil.GetRootUrl()); //string result = WXApi.CreateMenu(AdminUtil.GetAccessToken(this), AdminUtil.GetLoginUser(this).OrgID); //Response.Write(AdminUtil.GetRootUrl()); //string path = MapPath("UploadFile/aa.png"); //string id = WXApi.UploadMedia(AdminUtil.GetAccessToken(this), "image", path); //Response.Write(id); Response.Write(WXMsgUtil.CreateTextJson("abc", WXApi.GetOpenIDs(AdminUtil.GetAccessToken(this)))); }
public JsonResult SendNewGroup(string media_id) { string resultMsg = WXApi.Send(GetToken(), WXApiJson.CreateNewsJson(media_id, WXApi.GetOpenIDs(GetToken()))); return(Json("ok", JsonRequestBehavior.AllowGet)); }
public JsonResult SendText(string txt) { string resultMsg = WXApi.Send(GetToken(), WXApiJson.CreateTextJson(txt, WXApi.GetOpenIDs(GetToken()))); return(Json("ok", JsonRequestBehavior.AllowGet)); }
/// <summary> /// 群发 /// </summary> public string Send() { string type = Request["type"]; string data = Request["data"]; string access_token = AdminUtil.GetAccessToken(this); //获取access_token List <string> openidList = WXApi.GetOpenIDs(access_token); //获取关注者OpenID列表 UserInfo loginUser = AdminUtil.GetLoginUser(this); //当前登录用户 string resultMsg = null; //发送文本 if (type == "1") { resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateTextJson(data, openidList)); } //发送图片 if (type == "2") { string path = MapPath(data); if (!File.Exists(path)) { return("{\"code\":0,\"msg\":\"要发送的图片不存在\"}"); } string msg = WXApi.UploadMedia(access_token, "image", path); string media_id = Tools.GetJsonValue(msg, "media_id"); resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateImageJson(media_id, openidList)); } //发送图文消息 if (type == "3") { DataTable dt = ImgItemDal.GetImgItemTable(loginUser.OrgID, data); string articlesJson = ImgItemDal.GetArticlesJsonStr(this, access_token, dt); string newsMsg = WXApi.UploadNews(access_token, articlesJson); string newsid = Tools.GetJsonValue(newsMsg, "media_id"); resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateNewsJson(newsid, openidList)); } //结果处理 if (!string.IsNullOrWhiteSpace(resultMsg)) { string errcode = Tools.GetJsonValue(resultMsg, "errcode"); string errmsg = Tools.GetJsonValue(resultMsg, "errmsg"); if (errcode == "0") { return("{\"code\":1,\"msg\":\"\"}"); } else { return("{\"code\":0,\"msg\":\"errcode:" + errcode + ", errmsg:" + errmsg + "\"}"); } } else { return("{\"code\":0,\"msg\":\"type参数错误\"}"); } }