Wechat-Group / WxJava

微信开发 Java SDK ,支持包括微信支付,开放平台,小程序,企业微信,视频号,公众号等的后端开发
Apache License 2.0
29.85k stars 8.55k forks source link

微信小程序获取手机号出现com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ #1132

Closed leeue14 closed 5 years ago

leeue14 commented 5 years ago

简要描述

在做微信获取手机号的时候出现了了问题,测了几次,有几次出现了问题,有几次没有出现问题

-- 没有问题的json { "code":"061fwK8b17WQhx0lFv8b1RTU8b1fwK82", "vType":"web", "appid":"xxxxx", "encryptedData":"k6oZBniVJJkhgGIyr5+kjJxTRWay3F++m/4q6M1SwXe41psiyRR+Ibnvb1R6O4vxn3JBZeMKnu5WSyDcrWkAf1FwfI7inIQxciKlh3sbBXamQu/1t3grNf/r8jE/JYjVRXGdbmNoQZYTSixMjQTH88cqKMYKkZxdWRowwrr8HqPKDn/om+OFQRM2sy5Xa+JPD2/dX8xnpGrhlMxpdueaFA==", "sign":"8c59ee095d969e77f3e6b713f14bdbf5", "mpOpenId":"oinRC5pnVtNca8et94g0f1JnG3n0", "iv":"tk5yUpo6Kd74qqEtVfrKIQ==", "vCode":"100" }

有问题的 { "code":"061vQeo308kgKK1TBbo306Bzo30vQeoi", "vType":"web", "appid":"xxxxx", "encryptedData":"s6S93LTZI8fU5ZatvusooR8e5u1lrbfmnHdYy4iSMnEdB9m0Bojgx85pW32iOruWmT7gjLaCmayRxQGVMvT6z3apwd8cIm8srkKZcnXttaEyZRZh0/SywhS5+J0hzxPM7j16ZAuKdyf8CkPW5wVhCj1qs7TFP46jvYtKP3ifV2rfAYjpPiyPSP/wcuNdkc4/rbUxUTRwm1On39h+1fxs6w==", "sign":"8c59ee095d969e77f3e6b713f14bdbf5", "mpOpenId":"oinRC5pnVtNca8et94g0f1JnG3n0", "iv":"ZxO4tNtxOLlvCuRCpaHfJw==", "vCode":"100" }

模块版本情况

期待结果 和 实际情况

尽量详细描述

重现步骤

日志

[ ERROR] [2019-07-26 10:49:19] org.springframework.boot.web.support.ErrorPageFilter [176] - Forwarding to error page from request [/api/inquiry/phone] due to exception [java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $] com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) at com.google.gson.Gson.fromJson(Gson.java:887) at com.google.gson.Gson.fromJson(Gson.java:852) at com.google.gson.Gson.fromJson(Gson.java:801) at com.google.gson.Gson.fromJson(Gson.java:773) at cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo.fromJson(WxMaPhoneNumberInfo.java:22) at cn.binarywang.wx.miniapp.api.impl.WxMaUserServiceImpl.getPhoneNoInfo(WxMaUserServiceImpl.java:70) at com.kangsai.inquiry.service.impl.InquiryWxInfoServiceImpl.wxUserPhone(InquiryWxInfoServiceImpl.java:107) at com.kangsai.inquiry.resource.InquiryWxController.phone(InquiryWxController.java:61) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.s

leeue14 commented 5 years ago

版本使用的是最新的 3.4.0</weixin-java-miniapp.version>