forked from xeon2007/SpringBoot_Wechat_Sell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeixinController.java
More file actions
27 lines (24 loc) · 1021 Bytes
/
WeixinController.java
File metadata and controls
27 lines (24 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.ldlood.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
/**
* Created by Ldlood on 2017/7/23.
*/
@RestController
@RequestMapping("/weixin")
@Slf4j
public class WeixinController {
@GetMapping("/auth")
public void auth(@RequestParam("code") String code) {
log.info("进入auth方法........");
log.info("code={}", code);
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx3c93e6e76c50dad0&secret=d19207a865cc1a73891f2b96cab1c75a&code=" + code + "&grant_type=authorization_code";
RestTemplate restTemplate = new RestTemplate();
String response = restTemplate.getForObject(url, String.class);
log.info("response={}", response);
}
}