微信小程序> NO.3微信第三方平台代创建小程序审核发布以及小程序信息(头像,名称,简介)修改

NO.3微信第三方平台代创建小程序审核发布以及小程序信息(头像,名称,简介)修改

浏览量:614 时间: 来源:落魄的Java开发

https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21538208049W8uwq&token=&lang=zh_CN

???最好先熟悉以上文档???

正文:

1:创建小程序接口

        @PostMapping("creatApp")    @ApiImplicitParam(name = "companyVO", dataType = "CompanyVO")    @ApiOperation("创建小程序")    public ApiResponse creatApp(@RequestBody CompanyVO companyVO) {        String componentAccessToken = getComponentAccessToken();        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/cgi-bin/component/fastregisterweapp?action=create&component_access_token=");        stf.append(componentAccessToken);        Map<String, Object> map = new HashMap();        map.put("name", companyVO.getCompanyName());        map.put("code", companyVO.getCompanyCode());        map.put("code_type", companyVO.getCompanyCodeType());        map.put("legal_persona_wechat", companyVO.getWeChatAccount());        map.put("legal_persona_name", companyVO.getMerchantName());        map.put("component_phone", companyVO.getMerchantPhone());        ResponseEntity<String> entity = restTemplate.postForEntity(stf.toString(), map, String.class);        //状态码,0成功,其他失败        if (entity.getStatusCode().equals(HttpStatus.OK) && JSONObject.parseObject(entity.getBody()).getInteger("errcode") == 0) {            log.info("创建小程序=========》【{}】", entity.getBody());        } else {            log.error("创建小程序=========》失败!");        }        return ResponseUtil.success(entity.getBody());    }

CompanyVO:如下

{    "name": "tencent",   // 企业名    "code": "123",         // 企业代码    "code_type": 1, // 企业代码类型(1:统一社会信用代码, 2:组织机构代码,3:营业执照注册号)    "legal_persona_wechat": "123",   // 法人微信    "legal_persona_name":"pony" ,   // 法人姓名    "component_phone":"1234567" //第三方联系电话   }

返回结果:

{    "errcode":0,  // 状态码,0成功,其他失败    "errmsg":"OK"  // 错误信息}

失败

-1        非法action参数invalid action89249该主体已有任务执行中,距上次任务24h后再试task running89247内部错误inner error86004无效微信号invalid wechat61070法人姓名与微信号不一致name, wechat name not in accordance89248企业代码类型无效,请选择正确类型填写invalid code type89250未找到该任务task not found89251待法人人脸核身校验legal person checking89252法人&企业信息一致性校验中front checking89253缺少参数lack of some params89254第三方权限集不全,补全权限集全网发布后生效lack of some component rights

2:创建成功后。通过法人&企业主体校验,平台向法人微信下发模板消息。法人需在24小时内点击消息,进行身份证信息与人脸识别信息收集;

3:信息收集完毕,验证通过后,即可创建已认证的小程序。第三方平台服务器可以收到创建appid信息(通过授权登录相关-授权事件接收URL接收信息);第三方获得小程序appid后,可调用代码开发相关接口,完成后续的小程序代码开发。

   /**     * 消息与事件接收URL     */    @PostMapping("receiveComponentVerifyTicket/{APPID}")    public String receiveComponentVerifyTicket(HttpServletRequest request) {        log.info("消息与事件接收URL=========》开始【{}】", JSON.toJSONString(request.getParameterMap()));        /*log.info("消息与事件接收URL=====================》【{}】", request.getParameterMap().get("AppId"));        String[] AppId = request.getParameterMap().get("AppId");        redisUtil.set("APP_ID", StringUtils.join(AppId), 7200);*/        return "success";    }

当然熟悉的话,直接让授权方给你发小程序的APPID也可以,创建成功后,授权方会受到微信的通知,可以看的到自己的小程序APPID,但是没办法登录,因为是通过第三方平台接口创建的。

4:小程序虽然创建好,但是是空的,需要部署代码,代码如下

    @GetMapping("commitCode")    @ResponseBody    @ApiImplicitParams({            @ApiImplicitParam(name = "desc", value = "备注", required = true, dataType = "string"),            @ApiImplicitParam(name = "templateId", value = "模板ID", required = true, dataType = "int"),            @ApiImplicitParam(name = "version", value = "版本号", required = true, dataType = "string")    })    @ApiOperation("为已经授权的小程序部署代码")    public ApiResponse commitCode(String desc, Integer templateId, String version) {        String authorizerAccesstoken = String.valueOf(redisUtil.get("authorizer_access_token"));        String appId = String.valueOf(redisUtil.get("authorizer_appid"));        log.error("为已经授权的小程序部署代码=========》开始!");        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/wxa/commit?access_token=");        stf.append(authorizerAccesstoken);        Map<String, Object> map = new HashMap();        map.put("template_id", templateId);        map.put("user_version", version);        //第三方自定义的配置        Map extMap = new HashMap();        //授权第三方的APPID        extMap.put("extAppid", appId);        map.put("ext_json", JSON.toJSONString(extMap));        map.put("user_desc", desc);        ResponseEntity<String> entity = restTemplate.postForEntity(stf.toString(), map, String.class);        if (entity.getStatusCode().equals(HttpStatus.OK)) {            log.info("为已经授权的小程序部署代码=========》【{}】", entity.getBody());        } else {            log.error("为已经授权的小程序部署代码=========》失败!");        }        return ResponseUtil.success(entity.getBody());    }

成功返回:

{"errcode":0,"errmsg":"ok",}

上述接口的模板ID,版本号,备注,在第三方平台小程序模版库可以看的到,通过微信开发者工具去上传代码,去生成模板库。具体参数太多不一一描述,都在微信第三方平台代小程序实现业务的 代码管理模块里去找这个接口描述

5:部署完代码,可以预览小程序(体验版)

    @GetMapping("qrCode")    @ApiOperation("预览小程序")    public ApiResponse qrCode() {        String authorizerAccesstoken = redisUtil.get("authorizer_access_token").toString();        log.error("预览小程序=========》开始!");        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/wxa/get_qrcode?access_token=");        stf.append(authorizerAccesstoken);        log.info("预览小程序=========》【{}】", stf.toString());        return ResponseUtil.success(stf.toString());    }

authorizer_access_token 怎么获取,在上一篇文章中写到过,点此链接查看

6:将第三方平台部署的代码包提交审核,微信需要做校验,通过后才能看的到,否则只能预览体验版小程序

为小程序设置类目,如果不设置类目是不允许发布的

这个接口没写,我是用postman测试的

https://api.weixin.qq.com/cgi-bin/wxopen/addcategory?access_token=该接口文档上也有

获取授权小程序帐号已设置的类目

    @GetMapping("/getCategory")    @ApiOperation("获取授权小程序帐号已设置的类目")    public ApiResponse getCategory() {        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/wxa/get_category?access_token=");        String authorizerAccessToken = String.valueOf(redisUtil.get("authorizer_access_token"));        stf.append(authorizerAccessToken);        ResponseEntity<String> entity = restTemplate.getForEntity(stf.toString(), String.class);        if (entity.getStatusCode().equals(HttpStatus.OK)) {            log.info("获取授权小程序帐号已设置的类目=========》【{}】", entity.getBody());        } else {            log.error("获取授权小程序帐号已设置的类目=========》失败!");        }        return ResponseUtil.success(entity.getBody());    }

获取小程序的第三方提交代码的页面配置(仅供第三方开发者代小程序调用)

    @GetMapping("getPage")    @ApiOperation("获取小程序的第三方提交代码的页面配置")    public ApiResponse getPage() {        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/wxa/get_page?access_token=");        String authorizerAccessToken = String.valueOf(redisUtil.get("authorizer_access_token"));        stf.append(authorizerAccessToken);        ResponseEntity<String> entity = restTemplate.getForEntity(stf.toString(), String.class);        if (entity.getStatusCode().equals(HttpStatus.OK)) {            log.info("获取小程序的第三方提交代码的页面配置=========》【{}】", entity.getBody());        } else {            log.error("获取小程序的第三方提交代码的页面配置=========》失败!");        }        return ResponseUtil.success(entity.getBody());    }

将第三方提交的代码包提交审核(仅供第三方开发者代小程序调用),该接口需要前两个接口返回来的数据,

SubmitAuditVO:参数如下,这些所填的参数都可以通过上述两个接口获取
public class SubmitAuditVO {    @ApiModelProperty("提交审核项的一个列表")    private List<SubmitAuditAddressVO> itemList;    @ApiModelProperty("反馈内容,不超过200字")    private String feedbackInfo;    @ApiModelProperty("图片media_id列表,中间用“丨”分割,xx丨yy丨zz,不超过5张图片")    private String feedbackStuff;}
public class SubmitAuditAddressVO {    @ApiModelProperty("小程序的页面")    private String address;    @ApiModelProperty("小程序的标签,多个标签用空格分隔,标签不能多于10个,标签长度不超过20")    private String tag;    @ApiModelProperty("一级类目")    private String firstClass;    @ApiModelProperty("二级类目")    private String secondClass;    @ApiModelProperty("三级类目")    private String thirdClass;    @ApiModelProperty("一级类目的ID")    private String firstId;    @ApiModelProperty("二级类目的ID")    private String secondId;    @ApiModelProperty("三级类目的ID")    private String thirdId;    @ApiModelProperty("小程序页面的标题,标题长度不超过32")    private String title;}
    @PostMapping("submitAudit")    @ApiOperation("将第三方提交的代码包提交审核")    @ApiImplicitParam(name = "submitAuditVO", dataType = "SubmitAuditVO")    public ApiResponse submitAudit(@RequestBody SubmitAuditVO submitAuditVO) {        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/wxa/submit_audit?access_token=");        String authorizerAccessToken = String.valueOf(redisUtil.get("authorizer_access_token"));        stf.append(authorizerAccessToken);        Map<String, Object> parmMap = new HashMap(3);        List<SubmitAuditAddressVO> list = submitAuditVO.getItemList();        List<Map<String, String>> mapList = new ArrayList();        list.forEach(submitAuditAddressVO -> {            Map<String, String> map = new HashMap();            map.put("address", submitAuditAddressVO.getAddress());            map.put("tag", submitAuditAddressVO.getTag());            if (!StringUtils.isEmpty(submitAuditAddressVO.getFirstClass())) {                map.put("first_class", submitAuditAddressVO.getFirstClass());            }            if (!StringUtils.isEmpty(submitAuditAddressVO.getSecondClass())) {                map.put("second_class", submitAuditAddressVO.getSecondClass());            }            if (!StringUtils.isEmpty(submitAuditAddressVO.getThirdClass())) {                map.put("third_class", submitAuditAddressVO.getThirdClass());            }            if (!StringUtils.isEmpty(submitAuditAddressVO.getFirstId())) {                map.put("first_id", submitAuditAddressVO.getFirstId());            }            if (!StringUtils.isEmpty(submitAuditAddressVO.getSecondId())) {                map.put("second_id", submitAuditAddressVO.getSecondId());            }            if (!StringUtils.isEmpty(submitAuditAddressVO.getThirdId())) {                map.put("third_id", submitAuditAddressVO.getThirdId());            }            map.put("title", submitAuditAddressVO.getTitle());            mapList.add(map);        });        if (!StringUtils.isEmpty(submitAuditVO.getFeedbackInfo())) {            parmMap.put("feedback_info", submitAuditVO.getFeedbackInfo());        }        if (!StringUtils.isEmpty(submitAuditVO.getFeedbackStuff())) {            parmMap.put("feedback_stuff", submitAuditVO.getFeedbackStuff());        }        parmMap.put("item_list", mapList);        log.info("请求参数【{}】=============================》", parmMap);        ResponseEntity<String> entity = restTemplate.postForEntity(stf.toString(), parmMap, String.class);        if (entity.getStatusCode().equals(HttpStatus.OK)) {            log.info("将第三方提交的代码包提交审核=========》【{}】", entity.getBody());        } else {            log.error("将第三方提交的代码包提交审核=========》失败!");        }        return ResponseUtil.success(entity.getBody());    }

正确返回:

{"errcode":0,"errmsg":"ok","auditid":1234567}可通过 auditid 去查询审核状态

7:修改小程序基本信息

修改名称
    @GetMapping("setNickName")    @ApiOperation("修改小程序名字")    public ApiResponse setNickName(String nickName) {        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/wxa/setnickname?access_token=");        String authorizerAccessToken = String.valueOf(redisUtil.get("authorizer_access_token"));        stf.append(authorizerAccessToken);        Map<String, String> parmMap = new HashMap();        parmMap.put("nick_name", nickName);        ResponseEntity<String> entity = restTemplate.postForEntity(stf.toString(), parmMap, String.class);        if (entity.getStatusCode().equals(HttpStatus.OK)) {            log.info("修改小程序名字=========》【{}】", entity.getBody());        } else {            log.error("修改小程序名字=========》失败!");        }        return ResponseUtil.success(entity.getBody());    }

正确返回:

{    "errcode": 0,    "errmsg": "ok",    "wording": "",    "audit_id": 12345}可通过audit_id 去查询审核状态,具体参考第三方平台代小程序实现业务小程序基本信息设置里的接口

修改功能简介

    @ApiOperation("修改功能介绍")    @GetMapping("modifySignature")    //signature 功能介绍(简介)    public ApiResponse modifySignature(String signature) {        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/cgi-bin/account/modifysignature?access_token=");        String authorizerAccessToken = String.valueOf(redisUtil.get("authorizer_access_token"));        stf.append(authorizerAccessToken);        Map<String, String> parmMap = new HashMap();        parmMap.put("signature", signature);        ResponseEntity<String> entity = restTemplate.postForEntity(stf.toString(), parmMap, String.class);        if (entity.getStatusCode().equals(HttpStatus.OK)) {            log.info("修改功能介绍=========》【{}】", entity.getBody());        } else {            log.error("修改功能介绍=========》失败!");        }        return ResponseUtil.success(entity.getBody());    }

正确返回:

{    "errcode": 0,    "errmsg": "ok",}

修改头像

    @ApiOperation("修改头像")    @PostMapping("modifyHeadImage")    public ApiResponse modifyHeadImage(@RequestBody ModifyHeadImageVO modifyHeadImageVO) {        StringBuffer stf = new StringBuffer("https://api.weixin.qq.com/cgi-bin/account/modifyheadimage?access_token=");        String authorizerAccessToken = String.valueOf(redisUtil.get("authorizer_access_token"));        stf.append(authorizerAccessToken);        Map<String, Object> parmMap = new HashMap();        parmMap.put("head_img_media_id", modifyHeadImageVO.getHeadImgMediaId());        parmMap.put("x1", Float.valueOf(modifyHeadImageVO.getX1()));        parmMap.put("y1", Float.valueOf(modifyHeadImageVO.getY1()));        parmMap.put("x2", Float.valueOf(modifyHeadImageVO.getX2()));        parmMap.put("y2", Float.valueOf(modifyHeadImageVO.getY2()));        log.info("修改头像请求参数==============================》【{}】", parmMap);        ResponseEntity<String> entity = restTemplate.postForEntity(stf.toString(), parmMap, String.class);        if (entity.getStatusCode().equals(HttpStatus.OK)) {            log.info("修改头像=========》【{}】", entity.getBody());        } else {            log.error("修改头像=========》失败!");        }        return ResponseUtil.success(entity.getBody());    }

modifyHeadImageVO:参数如下

{    "head_img_media_id": "mI-4E_sFh_2X3g-qmTIWD83RT78ytI1_6VfgFp_A3-Y2U5T_nLl3nm1xYTafFJ8p",    "x1": 0,    "y1": 0,    "x2": 0.7596899224806202,    "y2": 0.49,}注:head_img_media_id  参考微信素材管理文档,可以用临时生成。比如直接用curl  curl -F media=@D:background_imgtimg.jpg "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=你的access_token&type=TYPE"会返回给你一个id:如:rXXH2BHtQz8HiK7FDuG3HgzPhK-_VEIgfa5wWAt_5vDbJd31fHoPTu4oN6Esa_6R

7:以上信息全部搞定之后发布

参考第三方平台代小程序实现业务的服务器域名设置,我这个也是 postman 去操作的,注意添加域名要和你在第三方平台填写的资料上的域名一样,不然错误代码 85017。比如:www.baidu.com 和 baidu.com 也是有去别的,本人就是因为这个www 的问题 报了好久的错,可能是域名解析的问题吧,不太清楚

本人??:571726193  欢迎来交流。有什么问题也欢迎指出。

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎