Toggle navigation
Toggle navigation
This project
Loading...
Sign in
jiujian
/
client-customer-order-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhuyifan
2025-02-20 14:22:38 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
561c464aa00fcafeffba2ded17f38726cf2158d4
561c464a
1 parent
995c1246
print log
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletions
src/main/java/com/infoloop/tianting/service/client/WxMiniProgramHttpClient.java
src/main/java/com/infoloop/tianting/service/client/WxMiniProgramHttpClient.java
View file @
561c464
...
...
@@ -15,6 +15,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -79,7 +80,10 @@ public class WxMiniProgramHttpClient {
try
{
final
var
url
=
"https://api.weixin.qq.com/sns/jscode2session"
+
"?appid="
+
appId
+
"&secret="
+
appSecret
+
"&js_code="
+
code
+
"&grant_type=authorization_code"
;
final
var
response
=
restTemplate
.
getForEntity
(
url
,
WxUserOpenIdDto
.
class
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Collections
.
singletonList
(
MediaType
.
APPLICATION_JSON
));
HttpEntity
<
Void
>
requestEntity
=
new
HttpEntity
<>(
headers
);
ResponseEntity
<
WxUserOpenIdDto
>
response
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
WxUserOpenIdDto
.
class
);
return
response
.
getBody
();
}
catch
(
Exception
e
)
{
log
.
error
(
"Error fetching user openid"
,
e
);
...
...
Please
register
or
login
to post a comment