package com.liangjian.dataplatform.member.api;

import com.jfinal.weixin.sdk.api.*;
import com.jfinal.weixin.sdk.kit.ParaMap;
import com.jfinal.weixin.sdk.utils.HttpUtils;

/**
 * @Author: 黄子奇
 * @Date: 2019/11/29
 */
public class MySnsApi extends SnsApi {
    private static String oauth2Url = "https://api.weixin.qq.com/sns/oauth2/access_token";

    public MySnsApi() {
    }

    public static ApiResult oauth2(String code) {
        ApiConfig ac = ApiConfigKit.getApiConfig();
        ParaMap pm = ParaMap.create("appid", ac.getAppId())
                .put("secret", ac.getAppSecret())
                .put("code", code)
                .put("grant_type","authorization_code")
                .put("lang", "zh_CN");
        return new ApiResult(HttpUtils.get(oauth2Url, pm.getData()));
    }
}
