Java Code Examples for org.jeewx.api.core.exception.WexinReqException#printStackTrace()

The following examples show how to use org.jeewx.api.core.exception.WexinReqException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JwSendMessageAPITest.java    From jeewx-api with Apache License 2.0 6 votes vote down vote up
@Test
public void testSendMessageToOpenidsWithMedia() {
	// 多媒体文件按人发送
			WxMedia media = new WxMedia();
			media.setType("image");
			media.setFileName("showqrcode.jpg");
			media.setFilePath("F:\\img\\");
			try {
				Wxuser user = new Wxuser();
				user.setOpenid(touser);
				Wxuser[] wxusers = new Wxuser[1];
				wxusers[0]=user;
				service.sendMessageToOpenidsWithMedia(newAccessToken,wxusers, media);
			} catch (WexinReqException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
}
 
Example 2
Source File: JwDataCubeAPI.java    From jeewx-api with Apache License 2.0 6 votes vote down vote up
/**
 * 获取消息发送分布周数据-测试
 */
private static void testGetWxDataCubeStreamMsgDistWeekInfo(){
	System.out.println("test testGetWxDataCubeStreamMsgDistWeekInfo start ");
	JwDataCubeAPI s = new JwDataCubeAPI();
	try {
		List<WxDataCubeStreamMsgDistWeekInfo> msgInfoList = s.getWxDataCubeStreamMsgDistWeekInfo("a8UEhkxmxN269afPJ7SuY9vVroHPYiwm9Yv5gu_yK4GGsA60IafJ3N9We4ubabgZ4lsl4kd0zqcH7JC70UsQ951Ndur4ejSIz7VvroBJn4g","2015-01-01","2015-01-15");
		if(msgInfoList!=null&&msgInfoList.size()>0){
			for (WxDataCubeStreamMsgDistWeekInfo wxDataCubeStreamMsgInfo : msgInfoList) {
				System.out.println(wxDataCubeStreamMsgInfo.getRef_date()); 
				System.out.println(wxDataCubeStreamMsgInfo.getCount_interval()); 
			}
		}
		 
	} catch (WexinReqException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	System.out.println("test testGetWxDataCubeStreamMsgDistWeekInfo end ");
}
 
Example 3
Source File: JwDataCubeAPI.java    From jeewx-api with Apache License 2.0 6 votes vote down vote up
/**
 * 获取消息发送分布月数据-测试
 */
private static void testGetWxDataCubeStreamMsgDistMonthInfo(){
	System.out.println("test testGetWxDataCubeStreamMsgDistMonthInfo start ");
	JwDataCubeAPI s = new JwDataCubeAPI();
	try {
		List<WxDataCubeStreamMsgDistMonthInfo> msgInfoList = s.getWxDataCubeStreamMsgDistMonthInfo("a8UEhkxmxN269afPJ7SuY9vVroHPYiwm9Yv5gu_yK4GGsA60IafJ3N9We4ubabgZ4lsl4kd0zqcH7JC70UsQ951Ndur4ejSIz7VvroBJn4g","2015-01-01","2015-01-15");
		if(msgInfoList!=null&&msgInfoList.size()>0){
			for (WxDataCubeStreamMsgDistMonthInfo wxDataCubeStreamMsgInfo : msgInfoList) {
				System.out.println(wxDataCubeStreamMsgInfo.getRef_date()); 
				System.out.println(wxDataCubeStreamMsgInfo.getCount_interval()); 
			}
		}
		 
	} catch (WexinReqException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	System.out.println("test testGetWxDataCubeStreamMsgDistMonthInfo end ");
}
 
Example 4
Source File: JwMediaAPI.java    From jeewx-api with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args){
	 
	try {
		/*WxUpload s = WeixinMediaService.uploadMedia(
				"kY9Y9rfdcr8AEtYZ9gPaRUjIAuJBvXO5ZOnbv2PYFxox__uSUQcqOnaGYN1xc4N1rI7NDCaPm_0ysFYjRVnPwCJHE7v7uF_l1hI6qi6QBsA",
				"image","C:/Users/sfli.sir/Desktop/temp/2457331_160355071353_2.jpg");*/
		WxDwonload d = JwMediaAPI.downMedia(
				"kY9Y9rfdcr8AEtYZ9gPaRUjIAuJBvXO5ZOnbv2PYFxox__uSUQcqOnaGYN1xc4N1rI7NDCaPm_0ysFYjRVnPwCJHE7v7uF_l1hI6qi6QBsA",
				"wBSDL0sz3zqOSGEXG9kIht48V9W7pAQBK50rFKFx1dv6FXsVNROxcxLPMUa9L-yI",
				"C:/Users/sfli.sir/Desktop/temp/");
		System.out.println(d.getFileName());
	} catch (WexinReqException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 5
Source File: JwDataCubeAPI.java    From jeewx-api with Apache License 2.0 6 votes vote down vote up
/**
 * 获取消息发送分布数据-测试
 */
private static void testGetWxDataCubeStreamMsgDistInfo(){
	System.out.println("test testGetWxDataCubeStreamMsgDistInfo start ");
	JwDataCubeAPI s = new JwDataCubeAPI();
	try {
		List<WxDataCubeStreamMsgDistInfo> msgInfoList = s.getWxDataCubeStreamMsgDistInfo("a8UEhkxmxN269afPJ7SuY9vVroHPYiwm9Yv5gu_yK4GGsA60IafJ3N9We4ubabgZ4lsl4kd0zqcH7JC70UsQ951Ndur4ejSIz7VvroBJn4g","2015-01-01","2015-01-15");
		if(msgInfoList!=null&&msgInfoList.size()>0){
			for (WxDataCubeStreamMsgDistInfo wxDataCubeStreamMsgInfo : msgInfoList) {
				System.out.println(wxDataCubeStreamMsgInfo.getRef_date()); 
				System.out.println(wxDataCubeStreamMsgInfo.getCount_interval()); 
			}
		}
		 
	} catch (WexinReqException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	System.out.println("test testGetWxDataCubeStreamMsgDistInfo end ");
}
 
Example 6
Source File: JwThirdAPI.java    From jeewx-api with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args){
	 
	try {
		//String s = JwThirdAPI.getPreAuthCode("wx5412820bba6f6bd6","unisk");
		
		ApiComponentToken apiComponentToken = new ApiComponentToken();
		//apiComponentToken.setComponent_appid("wx5412820bba6f6bd6");
		apiComponentToken.setComponent_appid("wx056ae5bc88c95c55");
		apiComponentToken.setComponent_appsecret("0c79e1fa963cd80cc0be99b20a18faeb");
		apiComponentToken.setComponent_verify_ticket(null);
		String s = JwThirdAPI.getAccessToken(apiComponentToken);
		System.out.println(s);
	} catch (WexinReqException e) {
		e.printStackTrace();
	}
}
 
Example 7
Source File: OpenwxController.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/**
   * 一键授权功能
   * @param request
   * @param response
   * @throws IOException
   * @throws AesException
   * @throws DocumentException
   */
  @RequestMapping(value = "/goAuthor")
  public void goAuthor(HttpServletRequest request, HttpServletResponse response) throws IOException, AesException, DocumentException {
  	ApiComponentToken apiComponentToken = new ApiComponentToken();
  	apiComponentToken.setComponent_appid(COMPONENT_APPID);
  	apiComponentToken.setComponent_appsecret(COMPONENT_APPSECRET);
  	WeixinOpenAccountEntity  entity = getWeixinOpenAccount(APPID);
  	apiComponentToken.setComponent_verify_ticket(entity.getTicket());
  	try {
	String component_access_token = JwThirdAPI.getAccessToken(apiComponentToken);
	//预授权码
	String preAuthCode = JwThirdAPI.getPreAuthCode(COMPONENT_APPID, component_access_token);
	String url = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid="+COMPONENT_APPID+"&pre_auth_code="+preAuthCode+"&redirect_uri="+ResourceUtil.getConfigByName("domain")+"/rest/openwx/authorCallback";
	response.sendRedirect(url);
} catch (WexinReqException e) {
	e.printStackTrace();
}
  	
  }
 
Example 8
Source File: OpenWxController.java    From jeewx-boot with Apache License 2.0 6 votes vote down vote up
/**
   * 一键授权功能(仅支持公众号)
   * @param request
   * @param response
   * @throws IOException
   * @throws AesException
   * @throws DocumentException
   */
  @RequestMapping(value = "/goAuthor")
  public void goAuthor(HttpServletRequest request, HttpServletResponse response) throws IOException, AesException, DocumentException {
  	//从数据库获取ticket
  	WeixinOpenAccount  weixinOpenAccount = getWeixinOpenAccount(CommonWeixinProperties.component_appid);
  	try {
	String componentAccessToken = weixinOpenAccount.getComponentAccessToken();
	//预授权码
	String preAuthCode = JwThirdAPI.getPreAuthCode(CommonWeixinProperties.component_appid, componentAccessToken);
	//auth_type:要授权的帐号类型, 1则商户扫码后,手机端仅展示公众号、2表示仅展示小程序,3表示公众号和小程序都展示。
	String url = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid="+CommonWeixinProperties.component_appid+"&pre_auth_code="+preAuthCode+"&auth_type=1"+"&redirect_uri="+CommonWeixinProperties.domain+"/rest/openwx/authorCallback";
	response.sendRedirect(url);
} catch (WexinReqException e) {
	e.printStackTrace();
}
  }
 
Example 9
Source File: JwGetAutoReplyRuleAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	try {
		//String s = JwTokenAPI.getAccessToken("wx298c4cc7312063df","fbf8cebf983c931bd7c1bee1498f8605");
		String s = "chsqpXVzXmPgqgZrrZnQzxqEi2L-1qStuVDOeZ-hKlY-Gkdlca3Q2HE9__BXc5hNoU1Plpc56UyZ1QoaDMkRbVSi0iUUVb27GTMaTDBfmuY";
		JwGetAutoReplyRuleAPI.getAutoReplyInfoRule(s);
	} catch (WexinReqException e) {
		e.printStackTrace();
	}
}
 
Example 10
Source File: JwTokenAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args){
	 
	try {
		String s = JwTokenAPI.getAccessToken("wx00737224cb9dbc7d","b9479ebdb58d1c6b6efd4171ebe718b5");
		System.out.println(s);
	} catch (WexinReqException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 11
Source File: OpenwxController.java    From jeewx with Apache License 2.0 5 votes vote down vote up
public void replyApiTextMessage(HttpServletRequest request, HttpServletResponse response, String auth_code, String fromUserName) throws DocumentException, IOException {
      String authorization_code = auth_code;
      // 得到微信授权成功的消息后,应该立刻进行处理!!相关信息只会在首次授权的时候推送过来
      System.out.println("------step.1----使用客服消息接口回复粉丝----逻辑开始-------------------------");
      try {
      	ApiComponentToken apiComponentToken = new ApiComponentToken();
      	apiComponentToken.setComponent_appid(COMPONENT_APPID);
      	apiComponentToken.setComponent_appsecret(COMPONENT_APPSECRET);
      	WeixinOpenAccountEntity  entity = getWeixinOpenAccount(APPID);
      	apiComponentToken.setComponent_verify_ticket(entity.getTicket());
      	String component_access_token = JwThirdAPI.getAccessToken(apiComponentToken);
      	
      	System.out.println("------step.2----使用客服消息接口回复粉丝------- component_access_token = "+component_access_token + "---------authorization_code = "+authorization_code);
      	net.sf.json.JSONObject authorizationInfoJson = JwThirdAPI.getApiQueryAuthInfo(COMPONENT_APPID, authorization_code, component_access_token);
      	System.out.println("------step.3----使用客服消息接口回复粉丝-------------- 获取authorizationInfoJson = "+authorizationInfoJson);
      	net.sf.json.JSONObject infoJson = authorizationInfoJson.getJSONObject("authorization_info");
      	String authorizer_access_token = infoJson.getString("authorizer_access_token");
      	
      	
      	Map<String,Object> obj = new HashMap<String,Object>();
      	Map<String,Object> msgMap = new HashMap<String,Object>();
      	String msg = auth_code + "_from_api";
      	msgMap.put("content", msg);
      	
      	obj.put("touser", fromUserName);
      	obj.put("msgtype", "text");
      	obj.put("text", msgMap);
      	JwThirdAPI.sendMessage(obj, authorizer_access_token);
} catch (WexinReqException e) {
	e.printStackTrace();
}
      
  }
 
Example 12
Source File: JwSendMessageAPITest.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("static-access")
@Test
public void testSendMessageToGroupOrAllWithText() {
	// 按组群发微信文本
	// 获取分组
	/*
	 * String url =
	 * "https://api.weixin.qq.com/cgi-bin/groups/get?access_token=ACCESS_TOKEN"
	 * ; String requestUrl = url.replace("ACCESS_TOKEN", newAccessToken);
	 * JSONObject result = WxstoreUtils.httpRequest(requestUrl, "GET",
	 * null); System.out.println(result);
	 */

	// {"groups":[{"id":0,"count":44,"name":"未分组"},{"id":1,"count":0,"name":"黑名单"},{"id":2,"count":0,"name":"星标组"},{"id":100,"count":0,"name":"分组1"},{"id":101,"count":0,"name":"www"},{"id":102,"count":0,"name":"测试1"},{"id":103,"count":2,"name":"我的发送组"},{"id":104,"count":0,"name":"测试1"}]}
	// POST数据例子:{"openid":"oDF3iYx0ro3_7jD4HFRDfrjdCM58","to_groupid":108}

	// 移动用户至分组
	/*
	 * String url =
	 * "https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=ACCESS_TOKEN"
	 * ; String requestUrl = url.replace("ACCESS_TOKEN", newAccessToken);
	 * JSONObject openid =new JSONObject(); openid.put("openid", touser);
	 * openid.put("to_groupid", "101"); JSONObject result =
	 * WxstoreUtils.httpRequest(requestUrl, "POST", openid.toString());
	 * System.out.println(result);
	 */

	try {
		Group group = new Group();
		group.setId("101");
		SendMessageResponse response = service.sendMessageToGroupOrAllWithText(newAccessToken, false, group, "我的文本预览。。。");
		System.out.println(response);
	} catch (WexinReqException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
Example 13
Source File: JwSendMessageAPITest.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessageToOpenidsWithText() {
	// 文本信息安人发送
	try {
		Wxuser user = new Wxuser();
		user.setOpenid(touser);
		Wxuser[] wxusers = new Wxuser[1];
		wxusers[0]=user;
		SendMessageResponse response = service.sendMessageToOpenidsWithText(newAccessToken, wxusers, "我的文本预览。。。");
		System.out.println(response);
	} catch (WexinReqException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 14
Source File: JwGroupAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
/**
 * 3.0 获取所有分组信息
 */
private static void testGetAllGroup(){
	List<Group> groupList;
	try {
		groupList = JwGroupAPI.getAllGroup(TOKEN);
		for(Group g : groupList){
			System.out.println(g.getName());
		}
		//System.out.println("分组列表信息:"+groupList);
	} catch (WexinReqException e) {
		e.printStackTrace();
	}
}
 
Example 15
Source File: JwGroupAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
/**
 * 4.0 获取用户所在分组
 */
private static void testGetUserGroup(){
	String openid = "oSmm-vhtoFwRo0kaqIxVnw8INSFg";
	try {
		//JwUserAPI.getAllWxuser(TOKEN, "");
		String groupid = JwGroupAPI.getUserGroup(TOKEN,openid);
		System.out.println("该粉丝所在分组为:"+groupid);
	} catch (WexinReqException e) {
		e.printStackTrace();
	}
}
 
Example 16
Source File: JwGroupAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
/**
 * 5.0 更改用户所在分组
 */
private static void testGroupMemberMove(){
	String openid = "oSmm-vjkfKrkIw94VKciV5JSG8io";
	try {
		String groupid = JwGroupAPI.groupMemberMove(TOKEN,openid,"2");
		System.out.println("该粉丝所在分组为:"+groupid);
	} catch (WexinReqException e) {
		e.printStackTrace();
	}
}
 
Example 17
Source File: JwGroupAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
/**
 * 6.0 批量更改用户所在分组
 */
private static void testBatchGroupMemberMove(){
	List<String> openidList = new ArrayList<String>();
	String openid = "oSmm-vjkfKrkIw94VKciV5JSG8io";
	try {
		openidList.add(openid);
		String groupid = JwGroupAPI.batchGroupMemberMove(TOKEN,openidList,"101");
		System.out.println("该粉丝所在分组为:"+groupid);
	} catch (WexinReqException e) {
		e.printStackTrace();
	}
}
 
Example 18
Source File: JwGroupAPI.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
/**
 * 7.0 删除分组
 */
private static void testGroupDelete(){
	try {
		String errmsg = JwGroupAPI.groupDelete(TOKEN,"129");
		System.out.println("删除分组:"+errmsg);
	} catch (WexinReqException e) {
		e.printStackTrace();
	}
}
 
Example 19
Source File: Test.java    From jeewx-api with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	try {
		String s = JwTokenAPI.getAccessToken("wxa842e07813a1380a","80a457401915ccbc10da0971fa6d404a");
		System.out.println(JwUserAPI.getWxuser(s, "oGCDRjvr9L1NoqxbyXLReCVYVyV0").getCity());
	} catch (WexinReqException e) {
		e.printStackTrace();
	}
}
 
Example 20
Source File: JwMenuAPI.java    From jeewx-api with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args){
		String s="";
		try {
			s = "3DGIfJqqupzTPxvq_P-0ATDC2MDjFLqaz8S41SPmRIqLaA3PSb8FgN_PuhpZ5jEB4D6w7ZNeX3gbC3CfSOAz2wt4DxVKi2HD5BCjoecrB0Q";
//			s = JwTokenAPI.getAccessToken("wx00737224cb9dbc7d","b9479ebdb58d1c6b6efd4171ebe718b5");
//			s = JwTokenAPI.getAccessToken("wx298c4cc7312063df","fbf8cebf983c931bd7c1bee1498f8605");
			System.out.println(s);
//			WeixinButton button = new WeixinButton();
			CustomWeixinButtonConfig cb = JwMenuAPI.getAllMenuConfigure(s);
			
//			for(WeixinButton bb : b){
//				System.out.println(bb.toString());
//			}
//			List<WeixinButton> sub_button = new ArrayList<WeixinButton>();
//			List<WeixinButton> testsUb = new ArrayList<WeixinButton>();
//			WeixinButton w = new WeixinButton();
//			w.setName("测试菜单");
//			testsUb.add(w);
//			
//			WeixinButton w1 = new WeixinButton();
//			/*
//			   "type": "scancode_waitmsg", 
//               "name": "扫码带提示", 
//               "key": "rselfmenu_0_0",
//            */ 
//			w1.setName("测试sub菜单");
//			w1.setKey("rselfmenu_0_0");
//			w1.setType("scancode_waitmsg");
//			sub_button.add(w1);
//			w.setSub_button(sub_button);
//			
//			
//			//s = getMenuButtonJson("button",b);
//			/*Gson gson = new Gson();
//			System.out.println(json);*/
//			s= JwMenuAPI.createMenu(s,testsUb);
//			System.out.println(s);
		} catch (WexinReqException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}