|  | @ -41,14 +41,13 @@ public class SendNews {
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param url      请求地址 form表单url地址
 | 
	
		
			
				|  |  |      * @param filePath 文件在服务器保存路径
 | 
	
		
			
				|  |  |      * @return String url的响应信息返回值
 | 
	
		
			
				|  |  |      * @return String 上传的图片地址
 | 
	
		
			
				|  |  |      * @throws IOException
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public static String uploadImage(String url, String filePath) throws IOException {
 | 
	
		
			
				|  |  |         String result = null;
 | 
	
		
			
				|  |  |         filePath = "http:///ehr.yihu.com/wlyy/images/renew.png";
 | 
	
		
			
				|  |  |         File file = new File(filePath);
 | 
	
		
			
				|  |  |         System.out.println("file  ====> "+file);
 | 
	
		
			
				|  |  |         System.out.println("file  ====> " + file);
 | 
	
		
			
				|  |  |         if (!file.exists() || !file.isFile()) {
 | 
	
		
			
				|  |  |             throw new IOException("文件不存在");
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -127,7 +126,6 @@ public class SendNews {
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 上传图文消息文字素材
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -137,8 +135,10 @@ public class SendNews {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public static String uploadNesText(String accessToken, String url, JSONObject data) throws Exception {
 | 
	
		
			
				|  |  |         url = url.replaceFirst("ACCESS_TOKEN", accessToken);
 | 
	
		
			
				|  |  |         System.out.print("data======> " + data);
 | 
	
		
			
				|  |  |         //上传的图文消息数据,其中thumb_media_id是文件上传图片上传的id
 | 
	
		
			
				|  |  |         String result = HttpClientUtil.postBody(url, data);
 | 
	
		
			
				|  |  |         System.out.println("result ========> " + result);
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -159,46 +159,54 @@ public class SendNews {
 | 
	
		
			
				|  |  |         // 配置信息
 | 
	
		
			
				|  |  |         Properties systemConf = SystemConf.getInstance().getSystemProperties();
 | 
	
		
			
				|  |  |         //本地上传图片的路径及跳转路径
 | 
	
		
			
				|  |  |         String renewPath = systemConf.getProperty("patient_sign_again_pic_url");
 | 
	
		
			
				|  |  |         renewPath = renewPath.replace("{server}", systemConf.getProperty("server_url"));
 | 
	
		
			
				|  |  |         String renewPath = systemConf.getProperty("renew_path");
 | 
	
		
			
				|  |  |         String renewUrl = systemConf.getProperty("patient_sign_again_url");
 | 
	
		
			
				|  |  |         renewUrl = renewUrl.replaceAll("\\{server\\}", SystemConf.getInstance().getSystemProperties().getProperty("wechat_base_url"));
 | 
	
		
			
				|  |  |         renewUrl = renewUrl.replaceAll("\\{appId\\}", SystemConf.getInstance().getSystemProperties().getProperty("appId"));
 | 
	
		
			
				|  |  |         renewUrl = renewUrl.replaceAll("amp;","");
 | 
	
		
			
				|  |  |         renewUrl = renewUrl.replaceAll(";","&");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String signPath = systemConf.getProperty("doctor_qrcode_pic_url");
 | 
	
		
			
				|  |  |         signPath = signPath.replace("{server}", systemConf.getProperty("server_url"));
 | 
	
		
			
				|  |  |         String signPath = systemConf.getProperty("sign_path");
 | 
	
		
			
				|  |  |         String signUrl = systemConf.getProperty("doctor_subscribe_url");
 | 
	
		
			
				|  |  |         signUrl = signUrl.replaceAll("\\{server\\}", SystemConf.getInstance().getSystemProperties().getProperty("wechat_base_url"));
 | 
	
		
			
				|  |  |         signUrl = signUrl.replaceAll("\\{appId\\}", SystemConf.getInstance().getSystemProperties().getProperty("appId"));
 | 
	
		
			
				|  |  |         signUrl = signUrl.replaceAll("amp;","");
 | 
	
		
			
				|  |  |         signUrl = signUrl.replaceAll(";","&");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sendUrl = "http://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN&type=image";
 | 
	
		
			
				|  |  |         String getMediaUrl = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=image";//由sendUrl获取远程图片的mediaId
 | 
	
		
			
				|  |  |         String mediaurl = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=ACCESS_TOKEN";//ACCESS_TOKEN是获取到的access_token
 | 
	
		
			
				|  |  |         String groupUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=ACCESS_TOKEN";//根据openid发群发消息地址
 | 
	
		
			
				|  |  |         sendUrl = sendUrl.replace("ACCESS_TOKEN", accessToken);
 | 
	
		
			
				|  |  |         System.out.println("renewPath --> "+renewPath);
 | 
	
		
			
				|  |  |         System.out.println("signPath  --> "+signPath);
 | 
	
		
			
				|  |  |         String renewImage = SendNews.uploadImage(sendUrl, renewPath);
 | 
	
		
			
				|  |  |         String signImage = SendNews.uploadImage(sendUrl, signPath);
 | 
	
		
			
				|  |  |         getMediaUrl = getMediaUrl.replace("ACCESS_TOKEN", accessToken);
 | 
	
		
			
				|  |  |         System.out.println("renewPath --> " + renewPath);
 | 
	
		
			
				|  |  |         System.out.println("signPath  --> " + signPath);
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  |         String renewImage = SendNews.uploadImage(getMediaUrl, renewPath);
 | 
	
		
			
				|  |  |         String signImage = SendNews.uploadImage(getMediaUrl, signPath);
 | 
	
		
			
				|  |  |         System.out.println("renewImage==?" + renewImage);
 | 
	
		
			
				|  |  |         System.out.println("signImage==?" + signImage);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         JSONObject newsTextData = new JSONObject();
 | 
	
		
			
				|  |  |         JSONArray newsText = new JSONArray();
 | 
	
		
			
				|  |  | //            续签图文
 | 
	
		
			
				|  |  |         JSONObject data = new JSONObject();
 | 
	
		
			
				|  |  |         data.put("thumb_media_id", new JSONObject(renewImage).get("url"));
 | 
	
		
			
				|  |  |         data.put("author", "作者");
 | 
	
		
			
				|  |  |         data.put("thumb_media_id", new JSONObject(renewImage).get("media_id"));
 | 
	
		
			
				|  |  |         data.put("content_source_url", renewUrl);
 | 
	
		
			
				|  |  |         data.put("content", "续签图文消息内容");
 | 
	
		
			
				|  |  |         data.put("digest", "续签图文消息描述");
 | 
	
		
			
				|  |  |         data.put("content", "家庭医生续签提醒");
 | 
	
		
			
				|  |  |         data.put("title", "家庭医生续签提醒");
 | 
	
		
			
				|  |  |         data.put("show_cover_pic", 1);
 | 
	
		
			
				|  |  | //            签约图文
 | 
	
		
			
				|  |  |         JSONObject data1 = new JSONObject();
 | 
	
		
			
				|  |  |         data1.put("thumb_media_id", new JSONObject(signImage).get("url"));
 | 
	
		
			
				|  |  | //            data1.put("author","作者");
 | 
	
		
			
				|  |  |         data1.put("thumb_media_id", new JSONObject(signImage).get("media_id"));
 | 
	
		
			
				|  |  |         data1.put("content_source_url", signUrl);
 | 
	
		
			
				|  |  |         data1.put("content", "签约图文消息内容");
 | 
	
		
			
				|  |  | //            data1.put("digest","签约图文消息描述");
 | 
	
		
			
				|  |  | //            data1.put("show_cover_pic",1);
 | 
	
		
			
				|  |  |         data1.put("content", "欢迎关注厦门i健康,快来签约家庭医生吧~");
 | 
	
		
			
				|  |  |         data1.put("title", "欢迎关注厦门i健康,快来签约家庭医生吧~");
 | 
	
		
			
				|  |  |         data1.put("show_cover_pic", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         newsText.put(data1);
 | 
	
		
			
				|  |  |         newsText.put(data);
 | 
	
		
			
				|  |  |         newsTextData.put("articles", newsText);
 | 
	
		
			
				|  |  |         String media = SendNews.uploadNesText(accessToken, mediaurl, newsTextData);
 | 
	
		
			
				|  |  |         System.out.println("media+++++>" + media);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         JSONObject news = new JSONObject();
 | 
	
		
			
				|  |  |         JSONObject mapnews = new JSONObject();
 | 
	
	
		
			
				|  | @ -209,6 +217,9 @@ public class SendNews {
 | 
	
		
			
				|  |  |         news.put("msgtype", "mpnews");
 | 
	
		
			
				|  |  |         news.put("send_ignore_reprint", 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         System.out.println("to go sign =====> "+signUrl);
 | 
	
		
			
				|  |  |         System.out.println("to go renew =====> "+renewUrl);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         SendNews.sendNewspMessage(accessToken, groupUrl, news);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 |