🆕 #2206 【开放平台】增加第三方平台启动ticket推送接口

This commit is contained in:
hywr
2021-07-18 23:04:48 +08:00
committed by GitHub
parent d3730b361d
commit 9e3f256032
4 changed files with 150 additions and 114 deletions

View File

@ -1,10 +1,8 @@
package me.chanjar.weixin.open.api; package me.chanjar.weixin.open.api;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.bean.result.WxMinishopImageUploadResult;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.open.bean.WxOpenCreateResult; import me.chanjar.weixin.open.bean.WxOpenCreateResult;
@ -31,6 +29,10 @@ public interface WxOpenComponentService {
* The constant API_COMPONENT_TOKEN_URL. * The constant API_COMPONENT_TOKEN_URL.
*/ */
String API_COMPONENT_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_component_token"; String API_COMPONENT_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
/**
* 启动ticket推送服务
*/
String API_START_PUSH_TICKET = "https://api.weixin.qq.com/cgi-bin/component/api_start_push_ticket";
/** /**
* The constant API_CREATE_PREAUTHCODE_URL. * The constant API_CREATE_PREAUTHCODE_URL.
*/ */
@ -220,6 +222,13 @@ public interface WxOpenComponentService {
*/ */
boolean checkSignature(String timestamp, String nonce, String signature); boolean checkSignature(String timestamp, String nonce, String signature);
/**
* 启动ticket推送服务 该 API 用于启动ticket推送服务
*
* @throws WxErrorException 如果调用失败返回此异常
*/
void startPushTicket() throws WxErrorException;
/** /**
* Gets component access token. * Gets component access token.
* *

View File

@ -149,6 +149,17 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService {
} }
} }
@Override
public void startPushTicket() throws WxErrorException {
WxOpenConfigStorage config = getWxOpenConfigStorage();
JsonObject json = new JsonObject();
json.addProperty("component_appid", config.getComponentAppId());
json.addProperty("component_secret", config.getComponentAppSecret());
getWxOpenService().post(API_START_PUSH_TICKET, json.toString());
}
@Override @Override
public String getComponentAccessToken(boolean forceRefresh) throws WxErrorException { public String getComponentAccessToken(boolean forceRefresh) throws WxErrorException {
final WxOpenConfigStorage config = this.getWxOpenConfigStorage(); final WxOpenConfigStorage config = this.getWxOpenConfigStorage();

View File

@ -1,5 +1,10 @@
package me.chanjar.weixin.open.api.impl; package me.chanjar.weixin.open.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.api.WxOpenComponentService;
import me.chanjar.weixin.open.test.ApiTestModule;
import org.testng.annotations.Guice;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -8,153 +13,162 @@ import org.testng.annotations.Test;
* @author <a href="https://github.com/binarywang">Binary Wang</a> * @author <a href="https://github.com/binarywang">Binary Wang</a>
* @date 2020-06-06 * @date 2020-06-06
*/ */
@Guice(modules = ApiTestModule.class)
public class WxOpenComponentServiceImplTest { public class WxOpenComponentServiceImplTest {
@Test @Inject
public void testGetWxMpServiceByAppid() { WxOpenComponentService wxOpenComponentService;
}
@Test @Test
public void testGetWxMaServiceByAppid() { public void testGetWxMpServiceByAppid() {
} }
@Test @Test
public void testGetWxFastMaServiceByAppid() { public void testGetWxMaServiceByAppid() {
} }
@Test @Test
public void testGetWxOpenService() { public void testGetWxFastMaServiceByAppid() {
} }
@Test @Test
public void testGetWxOpenConfigStorage() { public void testGetWxOpenService() {
} }
@Test @Test
public void testCheckSignature() { public void testGetWxOpenConfigStorage() {
} }
@Test @Test
public void testGetComponentAccessToken() { public void testCheckSignature() {
} }
@Test @Test
public void testPost() { public void testGetComponentAccessToken() {
} }
@Test @Test
public void testTestPost() { public void testPost() {
} }
@Test @Test
public void testGet() { public void testTestPost() {
} }
@Test @Test
public void testTestGet() { public void testGet() {
} }
@Test @Test
public void testGetPreAuthUrl() { public void testTestGet() {
} }
@Test @Test
public void testTestGetPreAuthUrl() { public void testGetPreAuthUrl() {
} }
@Test @Test
public void testGetMobilePreAuthUrl() { public void testTestGetPreAuthUrl() {
} }
@Test @Test
public void testTestGetMobilePreAuthUrl() { public void testGetMobilePreAuthUrl() {
} }
@Test @Test
public void testRoute() { public void testTestGetMobilePreAuthUrl() {
} }
@Test @Test
public void testGetQueryAuth() { public void testRoute() {
} }
@Test @Test
public void testGetAuthorizerInfo() { public void testGetQueryAuth() {
} }
@Test @Test
public void testGetAuthorizerList() { public void testGetAuthorizerInfo() {
} }
@Test @Test
public void testGetAuthorizerOption() { public void testGetAuthorizerList() {
} }
@Test @Test
public void testSetAuthorizerOption() { public void testGetAuthorizerOption() {
} }
@Test @Test
public void testGetAuthorizerAccessToken() { public void testSetAuthorizerOption() {
} }
@Test @Test
public void testOauth2getAccessToken() { public void testGetAuthorizerAccessToken() {
} }
@Test @Test
public void testTestCheckSignature() { public void testOauth2getAccessToken() {
} }
@Test @Test
public void testOauth2refreshAccessToken() { public void testTestCheckSignature() {
} }
@Test @Test
public void testOauth2buildAuthorizationUrl() { public void testOauth2refreshAccessToken() {
} }
@Test @Test
public void testMiniappJscode2Session() { public void testOauth2buildAuthorizationUrl() {
} }
@Test @Test
public void testGetTemplateDraftList() { public void testMiniappJscode2Session() {
} }
@Test @Test
public void testGetTemplateList() { public void testGetTemplateDraftList() {
} }
@Test @Test
public void testAddToTemplate() { public void testGetTemplateList() {
} }
@Test @Test
public void testDeleteTemplate() { public void testAddToTemplate() {
} }
@Test @Test
public void testCreateOpenAccount() { public void testDeleteTemplate() {
} }
@Test @Test
public void testBindOpenAccount() { public void testCreateOpenAccount() {
} }
@Test @Test
public void testUnbindOpenAccount() { public void testBindOpenAccount() {
} }
@Test @Test
public void testGetOpenAccount() { public void testUnbindOpenAccount() {
} }
@Test @Test
public void testFastRegisterWeapp() { public void testGetOpenAccount() {
} }
@Test @Test
public void testFastRegisterWeappSearch() { public void testFastRegisterWeapp() {
} }
@Test
public void testFastRegisterWeappSearch() {
}
@Test
public void testStartPushTicket() throws WxErrorException {
wxOpenComponentService.startPushTicket();
}
} }

View File

@ -5,6 +5,7 @@ import com.google.inject.Module;
import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStream;
import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.xml.XStreamInitializer; import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import me.chanjar.weixin.open.api.WxOpenComponentService;
import me.chanjar.weixin.open.api.WxOpenMaService; import me.chanjar.weixin.open.api.WxOpenMaService;
import me.chanjar.weixin.open.api.WxOpenMpService; import me.chanjar.weixin.open.api.WxOpenMpService;
import me.chanjar.weixin.open.api.WxOpenService; import me.chanjar.weixin.open.api.WxOpenService;
@ -33,6 +34,7 @@ public class ApiTestModule implements Module {
binder.bind(TestConfigStorage.class).toInstance(config); binder.bind(TestConfigStorage.class).toInstance(config);
binder.bind(WxOpenService.class).toInstance(service); binder.bind(WxOpenService.class).toInstance(service);
binder.bind(WxOpenComponentService.class).toInstance(service.getWxOpenComponentService());
if (config.getTestMpAppId() != null && !config.getTestMpAppId().isEmpty()) { if (config.getTestMpAppId() != null && !config.getTestMpAppId().isEmpty()) {
//如果配置了测试公众号,则构建公众号服务依赖 //如果配置了测试公众号,则构建公众号服务依赖