微信小程序授权获取用户信息和手机号码
1.微信官方文档
登录:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html
手机号:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html
2.获取用户手机号步骤
3.java后台 直接上干活
3.1 ApiLoginController
import com.alibaba.fastjson.JSONObject;
import com.dyt.common.HttpClientUtils;
import com.dyt.common.exception.DYTException;
import com.dyt.config.WeixinLoginProperties;
import com.dyt.utils.WXBizDataCrypt;
import com.dyt.vo.R;
import com.google.gson.Gson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "微信小程序登录、获取手机号")
@RestController
public class ApiLoginController {
@ApiOperation(value = "登录")
@PostMapping("/wxlogin")
public R callback(String code,String encryptedData,String iv){
System.out.println("----------------------------------------------"