mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
#932 增加第三方平台快速创建小程序接口及相关的信息设置接口
* Add 接收API创建小程序成功的消息推送
实现快速创建小程序的新建、查询接口
增加WxOpenFastMaService(API创建的小程序专用的接口)
* Add 实现小程序名称设置及改名、微信认证名称检测、修改头像、修改功能介绍接口
* Add 实现所有通过API创建的小程序专属接口及相关结果类
* Add 添加三个复杂实体的单体测试
* Update 修复WxFastMaService 8.1接口:因为不同类目含有特定字段,目前没有完整的类目信息数据,为保证兼容性,放弃将response转换为实体
* Update 将快速创建小程序接口返回值更改为WxOpenResult
This commit is contained in:
@@ -10,6 +10,7 @@ import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerOptionResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,6 +27,7 @@ public interface WxOpenComponentService {
|
||||
String API_SET_AUTHORIZER_OPTION_URL = "https://api.weixin.qq.com/cgi-bin/component/api_set_authorizer_option";
|
||||
|
||||
String COMPONENT_LOGIN_PAGE_URL = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=%s&pre_auth_code=%s&redirect_uri=%s";
|
||||
|
||||
/**
|
||||
* 手机端打开授权链接
|
||||
*/
|
||||
@@ -45,6 +47,13 @@ public interface WxOpenComponentService {
|
||||
|
||||
String CREATE_OPEN_URL= "https://api.weixin.qq.com/cgi-bin/open/create";
|
||||
|
||||
/**
|
||||
* 快速创建小程序接口
|
||||
*/
|
||||
String FAST_REGISTER_WEAPP_URL = "https://api.weixin.qq.com/cgi-bin/component/fastregisterweapp?action=create";
|
||||
String FAST_REGISTER_WEAPP_SEARCH_URL = "https://api.weixin.qq.com/cgi-bin/component/fastregisterweapp?action=search";
|
||||
|
||||
|
||||
WxMpService getWxMpServiceByAppid(String appid);
|
||||
|
||||
/**
|
||||
@@ -55,6 +64,13 @@ public interface WxOpenComponentService {
|
||||
*/
|
||||
WxOpenMaService getWxMaServiceByAppid(String appid);
|
||||
|
||||
/**
|
||||
* 获取指定appid的快速创建的小程序服务
|
||||
* @param appid
|
||||
* @return
|
||||
*/
|
||||
WxOpenFastMaService getWxFastMaServiceByAppid(String appid);
|
||||
|
||||
WxOpenConfigStorage getWxOpenConfigStorage();
|
||||
|
||||
boolean checkSignature(String timestamp, String nonce, String signature);
|
||||
@@ -182,4 +198,37 @@ public interface WxOpenComponentService {
|
||||
* @return
|
||||
*/
|
||||
WxOpenCreateResult createOpenAccount(String appId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21538208049W8uwq&token=&lang=zh_CN
|
||||
* 第三方平台快速创建小程序
|
||||
* <pre>
|
||||
* 注意:创建任务逻辑串行,单次任务结束后才可以使用相同信息下发第二次任务,请注意规避任务阻塞
|
||||
* </pre>
|
||||
* @param name 企业名(需与工商部门登记信息一致)
|
||||
* @param code 企业代码
|
||||
* @param codeType 企业代码类型 1:统一社会信用代码(18位) 2:组织机构代码(9位xxxxxxxx-x) 3:营业执照注册号(15位)
|
||||
* @param legalPersonaWechat 法人微信号
|
||||
* @param legalPersonaName 法人姓名(绑定银行卡)
|
||||
* @param componentPhone 第三方联系电话(方便法人与第三方联系)
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult fastRegisterWeapp(String name, String code, String codeType, String legalPersonaWechat, String legalPersonaName, String componentPhone) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21538208049W8uwq&token=&lang=zh_CN
|
||||
* 查询第三方平台快速创建小程序的任务状态
|
||||
* <pre>
|
||||
* 注意:该接口只提供当下任务结果查询,不建议过分依赖该接口查询所创建小程序。
|
||||
* 小程序的成功状态可在第三方服务器中自行对账、查询。
|
||||
* 不要频繁调用search接口,消息接收需通过服务器查看。调用search接口会消耗接口整体调用quato
|
||||
* </pre>
|
||||
*
|
||||
* @param name 企业名(需与工商部门登记信息一致)
|
||||
* @param legalPersonaWechat 法人微信号
|
||||
* @param legalPersonaName 法人姓名(绑定银行卡)
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWechat, String legalPersonaName) throws WxErrorException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
package me.chanjar.weixin.open.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.open.bean.fastma.WxFastMaCategory;
|
||||
import me.chanjar.weixin.open.bean.result.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 微信开放平台【快速创建小程序】的专用接口
|
||||
* https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21528465979XX32V&token=&lang=zh_CN
|
||||
* 注意:该类的接口仅限通过快速创建小程序接口的小程序使用
|
||||
* </pre>
|
||||
* TODO 完善相应API的respons实体
|
||||
*
|
||||
* @author Hipple
|
||||
* @date 2019/01/23
|
||||
*/
|
||||
public interface WxOpenFastMaService extends WxMaService {
|
||||
|
||||
/**
|
||||
* 1 获取帐号基本信息
|
||||
*/
|
||||
String OPEN_GET_ACCOUNT_BASIC_INFO = "https://api.weixin.qq.com/cgi-bin/account/getaccountbasicinfo";
|
||||
|
||||
/**
|
||||
* 2 小程序名称设置及改名
|
||||
*/
|
||||
String OPEN_SET_NICKNAME = "https://api.weixin.qq.com/wxa/setnickname";
|
||||
|
||||
/**
|
||||
* 3 小程序改名审核状态查询
|
||||
*/
|
||||
String OPEN_API_WXA_QUERYNICKNAME = "https://api.weixin.qq.com/wxa/api_wxa_querynickname";
|
||||
|
||||
/**
|
||||
* 4 微信认证名称检测
|
||||
*/
|
||||
String OPEN_CHECK_WX_VERIFY_NICKNAME = "https://api.weixin.qq.com/cgi-bin/wxverify/checkwxverifynickname";
|
||||
|
||||
/**
|
||||
* 5 修改头像
|
||||
*/
|
||||
String OPEN_MODIFY_HEADIMAGE = "https://api.weixin.qq.com/cgi-bin/account/modifyheadimage";
|
||||
|
||||
/**
|
||||
* 6修改功能介绍
|
||||
*/
|
||||
String OPEN_MODIFY_SIGNATURE = "https://api.weixin.qq.com/cgi-bin/account/modifysignature";
|
||||
|
||||
/**
|
||||
* 7 换绑小程序管理员接口
|
||||
*/
|
||||
String OPEN_COMPONENT_REBIND_ADMIN = "https://api.weixin.qq.com/cgi- bin/account/componentrebindadmin";
|
||||
|
||||
/**
|
||||
* 8.1 获取账号可以设置的所有类目
|
||||
*/
|
||||
String OPEN_GET_ALL_CATEGORIES = "https://api.weixin.qq.com/cgi-bin/wxopen/getallcategories";
|
||||
/**
|
||||
* 8.2 添加类目
|
||||
*/
|
||||
String OPEN_ADD_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/addcategory";
|
||||
/**
|
||||
* 8.3 删除类目
|
||||
*/
|
||||
String OPEN_DELETE_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/deletecategory";
|
||||
/**
|
||||
* 8.4 获取账号已经设置的所有类目
|
||||
*/
|
||||
String OPEN_GET_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/getcategory";
|
||||
/**
|
||||
* 8.5 修改类目
|
||||
*/
|
||||
String OPEN_MODIFY_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/modifycategory";
|
||||
|
||||
|
||||
/**
|
||||
* 1.获取小程序的信息
|
||||
*
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxFastMaAccountBasicInfoResult getAccountBasicInfo() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 2.小程序名称设置及改名
|
||||
* <pre>
|
||||
* 若接口未返回audit_id,说明名称已直接设置成功,无需审核;若返回audit_id则名称正在审核中。
|
||||
* </pre>
|
||||
* @param nickname 昵称
|
||||
* @param idCard 身份证照片–临时素材mediaid(个人号必填)
|
||||
* @param license 组织机构代码证或营业执照–临时素材mediaid(组织号必填)
|
||||
* @param namingOtherStuff1 其他证明材料---临时素材 mediaid
|
||||
* @param namingOtherStuff2 其他证明材料---临时素材 mediaid
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxFastMaSetNickameResult setNickname(String nickname, String idCard, String license, String namingOtherStuff1, String namingOtherStuff2) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 3 小程序改名审核状态查询
|
||||
* @param auditId 审核单id
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxFastMaQueryNicknameStatusResult querySetNicknameStatus(String auditId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 4. 微信认证名称检测
|
||||
* @param nickname 名称
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxFastMaCheckNickameResult checkWxVerifyNickname(String nickname) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 5.修改头像
|
||||
* <pre>
|
||||
* 图片格式只支持:BMP、JPEG、JPG、GIF、PNG,大小不超过2M
|
||||
* 注:实际头像始终为正方形
|
||||
* </pre>
|
||||
* @param headImgMediaId 头像素材media_id
|
||||
* @param x1 裁剪框左上角x坐标(取值范围:[0, 1])
|
||||
* @param y1 裁剪框左上角y坐标(取值范围:[0, 1])
|
||||
* @param x2 裁剪框右下角x坐标(取值范围:[0, 1])
|
||||
* @param y2 裁剪框右下角y坐标(取值范围:[0, 1])
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult modifyHeadImage(String headImgMediaId, float x1, float y1, float x2, float y2) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 6.修改功能介绍
|
||||
* @param signature 简介:4-120字
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult modifySignature(String signature) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 7.3 管理员换绑
|
||||
* @param taskid 换绑管理员任务序列号(公众平台最终点击提交回跳到第三方平台时携带)
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult componentRebindAdmin(String taskid) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 8.1 获取账号可以设置的所有类目
|
||||
* <pre>
|
||||
* 因为不同类目含有特定字段
|
||||
* 目前没有完整的类目信息数据
|
||||
* 为保证兼容性,放弃将response转换为实体
|
||||
* </pre>
|
||||
* @return
|
||||
*/
|
||||
String getAllCategories() throws WxErrorException;
|
||||
|
||||
/**
|
||||
*8.2添加类目
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult addCategory(List<WxFastMaCategory> categoryList) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 8.3删除类目
|
||||
* @param first 一级类目ID
|
||||
* @param second 二级类目ID
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult deleteCategory(int first, int second) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 8.4获取账号已经设置的所有类目
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxFastMaBeenSetCategoryResult getCategory() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 8.5修改类目
|
||||
* @param category 实体
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorException;
|
||||
}
|
||||
@@ -11,10 +11,7 @@ import me.chanjar.weixin.common.util.http.URIUtil;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
||||
import me.chanjar.weixin.open.api.WxOpenComponentService;
|
||||
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
|
||||
import me.chanjar.weixin.open.api.WxOpenMaService;
|
||||
import me.chanjar.weixin.open.api.WxOpenService;
|
||||
import me.chanjar.weixin.open.api.*;
|
||||
import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken;
|
||||
import me.chanjar.weixin.open.bean.WxOpenComponentAccessToken;
|
||||
import me.chanjar.weixin.open.bean.WxOpenCreateResult;
|
||||
@@ -24,6 +21,7 @@ import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerOptionResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult;
|
||||
import me.chanjar.weixin.open.bean.result.WxOpenResult;
|
||||
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -40,6 +38,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
private static final Map<String, WxOpenMaService> WX_OPEN_MA_SERVICE_MAP = new Hashtable<>();
|
||||
private static final Map<String, WxMpService> WX_OPEN_MP_SERVICE_MAP = new Hashtable<>();
|
||||
private static final Map<String, WxOpenFastMaService> WX_OPEN_FAST_MA_SERVICE_MAP = new Hashtable<>();
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
private WxOpenService wxOpenService;
|
||||
@@ -79,6 +78,21 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
return wxOpenMaService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOpenFastMaService getWxFastMaServiceByAppid(String appId) {
|
||||
WxOpenFastMaService fastMaService = WX_OPEN_FAST_MA_SERVICE_MAP.get(appId);
|
||||
if (fastMaService == null) {
|
||||
synchronized (WX_OPEN_FAST_MA_SERVICE_MAP) {
|
||||
fastMaService = WX_OPEN_FAST_MA_SERVICE_MAP.get(appId);
|
||||
if (fastMaService == null) {
|
||||
fastMaService = new WxOpenFastMaServiceImpl(this, appId, getWxOpenConfigStorage().getWxMaConfig(appId));
|
||||
WX_OPEN_FAST_MA_SERVICE_MAP.put(appId, fastMaService);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fastMaService;
|
||||
}
|
||||
|
||||
public WxOpenService getWxOpenService() {
|
||||
return wxOpenService;
|
||||
}
|
||||
@@ -238,7 +252,7 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
getWxOpenConfigStorage().setComponentVerifyTicket(wxMessage.getComponentVerifyTicket());
|
||||
return "success";
|
||||
}
|
||||
//新增、跟新授权
|
||||
//新增、更新授权
|
||||
if (StringUtils.equalsAnyIgnoreCase(wxMessage.getInfoType(), "authorized", "updateauthorized")) {
|
||||
WxOpenQueryAuthResult queryAuth = wxOpenService.getWxOpenComponentService().getQueryAuth(wxMessage.getAuthorizationCode());
|
||||
if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) {
|
||||
@@ -246,6 +260,14 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
//快速创建小程序
|
||||
if (StringUtils.equalsIgnoreCase(wxMessage.getInfoType(), "notify_third_fasteregister") && wxMessage.getStatus () == 0) {
|
||||
WxOpenQueryAuthResult queryAuth = wxOpenService.getWxOpenComponentService().getQueryAuth(wxMessage.getAuthCode ());
|
||||
if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) {
|
||||
throw new NullPointerException("getQueryAuth");
|
||||
}
|
||||
return "success";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -398,4 +420,27 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
|
||||
|
||||
return WxOpenCreateResult.fromJson(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOpenResult fastRegisterWeapp(String name, String code, String codeType, String legalPersonaWechat, String legalPersonaName, String componentPhone) throws WxErrorException{
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("name",name);
|
||||
jsonObject.addProperty("code", code);
|
||||
jsonObject.addProperty("code_type", codeType);
|
||||
jsonObject.addProperty("legal_persona_wechat", legalPersonaWechat);
|
||||
jsonObject.addProperty("legal_persona_name", legalPersonaName);
|
||||
jsonObject.addProperty("component_phone", componentPhone);
|
||||
String response = post(FAST_REGISTER_WEAPP_URL, jsonObject.toString (), "component_access_token");
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWechat, String legalPersonaName) throws WxErrorException{
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("name",name);
|
||||
jsonObject.addProperty("legal_persona_wechat", legalPersonaWechat);
|
||||
jsonObject.addProperty("legal_persona_name", legalPersonaName);
|
||||
String response = post(FAST_REGISTER_WEAPP_SEARCH_URL, jsonObject.toString (), "component_access_token");
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
package me.chanjar.weixin.open.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.open.api.WxOpenComponentService;
|
||||
import me.chanjar.weixin.open.api.WxOpenFastMaService;
|
||||
import me.chanjar.weixin.open.bean.fastma.WxFastMaCategory;
|
||||
import me.chanjar.weixin.open.bean.result.*;
|
||||
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Hipple
|
||||
* @description
|
||||
* @since 2019/1/23 15:27
|
||||
*/
|
||||
public class WxOpenFastMaServiceImpl extends WxMaServiceImpl implements WxOpenFastMaService {
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger (this.getClass ());
|
||||
|
||||
private WxOpenComponentService wxOpenComponentService;
|
||||
private WxMaConfig wxMaConfig;
|
||||
private String appId;
|
||||
|
||||
public WxOpenFastMaServiceImpl (WxOpenComponentService wxOpenComponentService, String appId, WxMaConfig wxMaConfig) {
|
||||
this.wxOpenComponentService = wxOpenComponentService;
|
||||
this.appId = appId;
|
||||
this.wxMaConfig = wxMaConfig;
|
||||
initHttp ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaConfig getWxMaConfig () {
|
||||
return wxMaConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessToken (boolean forceRefresh) throws WxErrorException {
|
||||
return wxOpenComponentService.getAuthorizerAccessToken (appId, forceRefresh);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.获取小程序的信息,GET请求
|
||||
* <pre>
|
||||
* 注意:这里不能直接用小程序的access_token
|
||||
* </pre>
|
||||
*
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxFastMaAccountBasicInfoResult getAccountBasicInfo () throws WxErrorException {
|
||||
String response = get (OPEN_GET_ACCOUNT_BASIC_INFO, "");
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaAccountBasicInfoResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.小程序名称设置及改名
|
||||
*
|
||||
* @param nickname 昵称
|
||||
* @param idCard 身份证照片–临时素材mediaid(个人号必填)
|
||||
* @param license 组织机构代码证或营业执照–临时素材mediaid(组织号必填)
|
||||
* @param namingOtherStuff1 其他证明材料---临时素材 mediaid
|
||||
* @param namingOtherStuff2 其他证明材料---临时素材 mediaid
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxFastMaSetNickameResult setNickname (String nickname, String idCard, String license, String namingOtherStuff1, String namingOtherStuff2) throws WxErrorException {
|
||||
JsonObject params = new JsonObject ();
|
||||
params.addProperty ("nick_name", nickname);
|
||||
params.addProperty ("id_card", idCard);
|
||||
params.addProperty ("license", license);
|
||||
params.addProperty ("naming_other_stuff_1", namingOtherStuff1);
|
||||
params.addProperty ("naming_other_stuff_2", namingOtherStuff2);
|
||||
String response = post (OPEN_SET_NICKNAME, GSON.toJson (params));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaSetNickameResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3 小程序改名审核状态查询
|
||||
*
|
||||
* @param auditId 审核单id
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxFastMaQueryNicknameStatusResult querySetNicknameStatus (String auditId) throws WxErrorException {
|
||||
JsonObject params = new JsonObject ();
|
||||
params.addProperty ("audit_id", auditId);
|
||||
String response = post (OPEN_API_WXA_QUERYNICKNAME, GSON.toJson (params));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaQueryNicknameStatusResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4. 微信认证名称检测
|
||||
* <pre>
|
||||
* 命中关键字策略时返回命中关键字的说明描述
|
||||
* </pre>
|
||||
*
|
||||
* @param nickname 名称
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxFastMaCheckNickameResult checkWxVerifyNickname (String nickname) throws WxErrorException {
|
||||
JsonObject params = new JsonObject ();
|
||||
params.addProperty ("nick_name", nickname);
|
||||
String response = post (OPEN_CHECK_WX_VERIFY_NICKNAME, GSON.toJson (params));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaCheckNickameResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 5.修改头像
|
||||
* <pre>
|
||||
* 图片格式只支持:BMP、JPEG、JPG、GIF、PNG,大小不超过2M
|
||||
* 注:实际头像始终为正方形
|
||||
* </pre>
|
||||
*
|
||||
* @param headImgMediaId 头像素材media_id
|
||||
* @param x1 裁剪框左上角x坐标(取值范围:[0, 1])
|
||||
* @param y1 裁剪框左上角y坐标(取值范围:[0, 1])
|
||||
* @param x2 裁剪框右下角x坐标(取值范围:[0, 1])
|
||||
* @param y2 裁剪框右下角y坐标(取值范围:[0, 1])
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxOpenResult modifyHeadImage (String headImgMediaId, float x1, float y1, float x2, float y2) throws WxErrorException {
|
||||
JsonObject params = new JsonObject ();
|
||||
params.addProperty ("head_img_media_id", headImgMediaId);
|
||||
params.addProperty ("x1", x1);
|
||||
params.addProperty ("y1", y1);
|
||||
params.addProperty ("x2", x2);
|
||||
params.addProperty ("y2", y2);
|
||||
String response = post (OPEN_MODIFY_HEADIMAGE, GSON.toJson (params));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 6.修改功能介绍
|
||||
*
|
||||
* @param signature 简介:4-120字
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxOpenResult modifySignature (String signature) throws WxErrorException {
|
||||
JsonObject params = new JsonObject ();
|
||||
params.addProperty ("signature", signature);
|
||||
String response = post (OPEN_MODIFY_SIGNATURE, GSON.toJson (params));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 7.3 管理员换绑
|
||||
*
|
||||
* @param taskid 换绑管理员任务序列号(公众平台最终点击提交回跳到第三方平台时携带)
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxOpenResult componentRebindAdmin (String taskid) throws WxErrorException {
|
||||
JsonObject params = new JsonObject ();
|
||||
params.addProperty ("taskid", taskid);
|
||||
String response = post (OPEN_COMPONENT_REBIND_ADMIN, GSON.toJson (params));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8.1 获取账号可以设置的所有类目
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getAllCategories () throws WxErrorException {
|
||||
return get (OPEN_GET_ALL_CATEGORIES, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 8.2添加类目
|
||||
*
|
||||
* @param categoryList
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxOpenResult addCategory (List<WxFastMaCategory> categoryList) throws WxErrorException {
|
||||
Map<String, Object> map = new HashMap<> ();
|
||||
map.put ("categories", categoryList);
|
||||
String response = post (OPEN_ADD_CATEGORY, WxOpenGsonBuilder.create ().toJson (map));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8.3删除类目
|
||||
*
|
||||
* @param first 一级类目ID
|
||||
* @param second 二级类目ID
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxOpenResult deleteCategory (int first, int second) throws WxErrorException {
|
||||
JsonObject params = new JsonObject ();
|
||||
params.addProperty ("first", first);
|
||||
params.addProperty ("Second", second);
|
||||
String response = post (OPEN_DELETE_CATEGORY, GSON.toJson (params));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8.4获取账号已经设置的所有类目
|
||||
*
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxFastMaBeenSetCategoryResult getCategory () throws WxErrorException {
|
||||
String response = get (OPEN_GET_CATEGORY, "");
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxFastMaBeenSetCategoryResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8.5修改类目
|
||||
*
|
||||
* @param category 实体
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
@Override
|
||||
public WxOpenResult modifyCategory (WxFastMaCategory category) throws WxErrorException {
|
||||
String response = post (OPEN_MODIFY_CATEGORY, GSON.toJson (category));
|
||||
return WxOpenGsonBuilder.create ().fromJson (response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串对象转化为GsonArray对象
|
||||
*
|
||||
* @param strList
|
||||
* @return
|
||||
*/
|
||||
private JsonArray toJsonArray (List<String> strList) {
|
||||
JsonArray jsonArray = new JsonArray ();
|
||||
if (strList != null && ! strList.isEmpty ()) {
|
||||
for (String str : strList) {
|
||||
jsonArray.add (str);
|
||||
}
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user