/// <summary> /// 发送图片/语音给用户 /// </summary> /// <param name="AppId"></param> /// <param name="OpenId"></param> /// <param name="fileName"></param> /// <param name="fileType"></param> /// <returns></returns> public ActionResult SendImageUser(string AppId, string OpenId, string fileName, string fileType) { var Ap = new WX_AppManager().GetByPK(AppId); MediaService ser = new MediaService(Ap.AppId, Ap.AppSecret); JObject jo = ser.UploadTemp(fileName, fileType); //返回一个mediaid和url var result = ""; if (jo != null)//新增成功 { CustomService CS = new CustomService(Ap.AppId, Ap.AppSecret); if (fileType == "image") { result = CS.SendImage(OpenId, jo["media_id"].ToString()); } else if (fileType == "voice") { result = CS.SendVoice(OpenId, jo["media_id"].ToString()); } } return(Json(result, JsonRequestBehavior.AllowGet)); }