微信自訂菜單開發報錯

來源:互聯網
上載者:User

在自訂菜單生產時,報了下面的錯誤,原來其中的post地址要把https改成http才行。真蛋碎,如下面

http://api.weixin.qq.com/cgi-bin/menu/create?access_token=

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: basic constraints check failed: pathLenConstraint violated - this cert must be the last cert in the certification pathat com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown Source)at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source)at java.io.BufferedOutputStream.flushBuffer(Unknown Source)at java.io.BufferedOutputStream.flush(Unknown Source)at org.apache.commons.httpclient.methods.StringRequestEntity.writeRequest(StringRequestEntity.java:150)at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495)at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)at org.apache.jsp.test2_jsp._jspService(test2_jsp.java:74)at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)at java.lang.Thread.run(Unknown Source)Caused by: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: basic constraints check failed: pathLenConstraint violated - this cert must be the last cert in the certification pathat sun.security.validator.PKIXValidator.doValidate(Unknown Source)at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)at sun.security.validator.Validator.validate(Unknown Source)at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(Unknown Source)... 37 moreCaused by: java.security.cert.CertPathValidatorException: basic constraints check failed: pathLenConstraint violated - this cert must be the last cert in the certification pathat sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(Unknown Source)at sun.security.provider.certpath.PKIXCertPathValidator.doValidate(Unknown Source)at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(Unknown Source)at java.security.cert.CertPathValidator.validate(Unknown Source)... 42 more

附JAVApost 菜單代碼

// * 菜單建立 通過POST一個特定結構體,實現在用戶端建立自訂菜單。 //* @param menuList //* @param access_token// */public static void wxMenuPost(List menuList,String access_token){int maxButtonCount=3;int maxSubButtonCount=5;    String url = WXConfig.getMenuPostUrl()+access_token;    System.out.println("posturl---"+url);    String responeJsonStr ="{\"button\":[";  for(int i=0;i<menuList.size()&&i<maxButtonCount;i++){  WXMenuVO vo=(WXMenuVO)menuList.get(i);  List subList=vo.getSubList();  responeJsonStr+="{";  if(subList!=null && subList.size()>0){  responeJsonStr+="";  }else{  responeJsonStr+="\"type\":\"click\",";  }  responeJsonStr+="\"name\":\""+vo.getName()+"\",";  if(subList!=null && subList.size()>0){  responeJsonStr+="\"sub_button\":[";  for(int j=0;j<subList.size()&&j<maxSubButtonCount;j++){  System.out.println("j-----"+j);  WXMenuVO vo2=(WXMenuVO)subList.get(j);  responeJsonStr+="{"               +"\"type\":\"click\","               +"\"name\":\""+vo2.getName()+"\","               +"\"key\":\""+vo2.getKeyCode()+"\""               +"}"+(j==subList.size()-1?"":",");       }  responeJsonStr+="]";  }else{  responeJsonStr+="\"key\":\""+vo.getKeyCode()+"\"";  }  responeJsonStr+="}"+(i==menuList.size()-1?"":",");  }   responeJsonStr+="]}";      HttpClient client = new HttpClient();  PostMethod post = new PostMethod(url);  post.setRequestBody(responeJsonStr);  post.getParams().setContentCharset("utf-8");  //發送http請求  String respStr = "";  try {  client.executeMethod(post);  respStr = post.getResponseBodyAsString();  } catch (HttpException e) {  e.printStackTrace();  } catch (IOException e) {  e.printStackTrace();  }  System.out.println("responeJsonStr--"+responeJsonStr);  System.out.println("respStr--"+respStr);}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.