微信生态开发常用接口地址枚举类

/**
 * @description: 微信接口地址枚举
 * @author: Mr.Fang
 * @create: 2023-05-18
 **/

public enum WxEnum {


    BASIC_URL("小程序与公众号", "https://api.weixin.qq.com", ""),
    MCH_BASIC_URL("微信商户", "https://api.mch.weixin.qq.com", ""),
    DOMAIN_CGI_BIN("cgi-bin", "cgi-bin", ""),
    DOMAIN_SNS("sns", "sns", ""),
    DOMAIN_WXA("wxa", "wxa", ""),


    // https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getStableAccessToken.html
    ACCESS_STABLE_TOKEN("公众号或小程序接口调用凭据-稳定版(N次调用,有效期内不重置)", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_CGI_BIN.url, "stable_token"), "POST"),
    ACCESS_TOKEN("公众号或小程序接口调用凭据-基础版(N次调用,有效期内重置)", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_CGI_BIN.url, "token"), "POST"),

    // https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-info/phone-number/getPhoneNumber.html
    APPLET_NUMBER("小程序手机号", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_WXA.url, "business/getuserphonenumber?access_token="), "POST"),

    // https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-login/code2Session.html
    APPLET_OPEN_ID("小程序 OpenId", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_SNS.url, "jscode2session"), "GET"),

    // https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html
    APPLET_QR_CODE("无限制小程序码", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_WXA.url, "getwxacodeunlimit?access_token="), "GET"),

    // https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/sendMessage.html
    APPLET_MESSAGE_SUBSCRIBE("小程序订阅消息", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_CGI_BIN.url, "message/subscribe/send?access_token="), "POST"),

    // https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html
    WX_WEB_TOKEN("通过code换取网页授权access_token", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_SNS.url, "oauth2/access_token"), "POST"),

    // https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html
    WX_MESSAGE_TEMPLATE("公众号模板消息", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_CGI_BIN.url, "message/template/send?access_token="), "POST"),

    // https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html
    WX_MESSAGE_SUBSCRIBE("公众号订阅消息", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_CGI_BIN.url, "message/subscribe/bizsend?access_token="), "POST"),

    // https://developers.weixin.qq.com/doc/offiaccount/User_Management/Get_users_basic_information_UnionID.html#UinonId
    WX_USER_INFO_BATCH("公众号批量用信息", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_CGI_BIN.url, "user/info/batchget?access_token="), "POST"),

    // https://developers.weixin.qq.com/doc/offiaccount/User_Management/Get_users_basic_information_UnionID.html#UinonId
    WX_USER_INFO("公众号用户信息", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_CGI_BIN.url, "user/info"), "GET"),

    // https://developers.weixin.qq.com/doc/offiaccount/User_Management/Getting_a_User_List.html
    WX_USER_GET("公众号用户列表", String.format("%s/%s/%s", BASIC_URL.url, DOMAIN_CGI_BIN.url, "user/get"), "GET"),

    // https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_1
    MCH_RAD("微信红包", String.format("%s/%s", MCH_BASIC_URL.url, "mmpaymkttransfers/sendredpack"), "POST");

    private final String url;

    WxEnum(String desc, String url, String method) {
        this.url = url;
    }

    public String getUrl() {
        return url;
    }
}

 

posted @ 2023-05-18 09:11  天葬  阅读(57)  评论(0编辑  收藏  举报