mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-31 02:28:25 +08:00
🆕 #2206 【开放平台】增加第三方平台启动ticket推送接口
This commit is contained in:
@ -1,10 +1,8 @@
|
||||
package me.chanjar.weixin.open.api;
|
||||
|
||||
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.result.WxMinishopImageUploadResult;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.open.bean.WxOpenCreateResult;
|
||||
@ -31,6 +29,10 @@ public interface WxOpenComponentService {
|
||||
* The constant API_COMPONENT_TOKEN_URL.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -220,6 +222,13 @@ public interface WxOpenComponentService {
|
||||
*/
|
||||
boolean checkSignature(String timestamp, String nonce, String signature);
|
||||
|
||||
/**
|
||||
* 启动ticket推送服务 该 API 用于启动ticket推送服务
|
||||
*
|
||||
* @throws WxErrorException 如果调用失败返回此异常
|
||||
*/
|
||||
void startPushTicket() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* Gets component access token.
|
||||
*
|
||||
|
||||
@ -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
|
||||
public String getComponentAccessToken(boolean forceRefresh) throws WxErrorException {
|
||||
final WxOpenConfigStorage config = this.getWxOpenConfigStorage();
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -8,8 +13,12 @@ import org.testng.annotations.Test;
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-06-06
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxOpenComponentServiceImplTest {
|
||||
|
||||
@Inject
|
||||
WxOpenComponentService wxOpenComponentService;
|
||||
|
||||
@Test
|
||||
public void testGetWxMpServiceByAppid() {
|
||||
}
|
||||
@ -157,4 +166,9 @@ public class WxOpenComponentServiceImplTest {
|
||||
@Test
|
||||
public void testFastRegisterWeappSearch() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartPushTicket() throws WxErrorException {
|
||||
wxOpenComponentService.startPushTicket();
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import com.google.inject.Module;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import me.chanjar.weixin.common.error.WxRuntimeException;
|
||||
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.WxOpenMpService;
|
||||
import me.chanjar.weixin.open.api.WxOpenService;
|
||||
@ -33,6 +34,7 @@ public class ApiTestModule implements Module {
|
||||
|
||||
binder.bind(TestConfigStorage.class).toInstance(config);
|
||||
binder.bind(WxOpenService.class).toInstance(service);
|
||||
binder.bind(WxOpenComponentService.class).toInstance(service.getWxOpenComponentService());
|
||||
|
||||
if (config.getTestMpAppId() != null && !config.getTestMpAppId().isEmpty()) {
|
||||
//如果配置了测试公众号,则构建公众号服务依赖
|
||||
|
||||
Reference in New Issue
Block a user