Package com.foxinmy.weixin4j.mp
Class WeixinComponentProxy
- java.lang.Object
-
- com.foxinmy.weixin4j.mp.WeixinComponentProxy
-
public class WeixinComponentProxy extends Object
微信第三方应用接口实现- Since:
- JDK 1.6
- Author:
- jinyu(foxinmy@gmail.com)
- See Also:
ComponentApi, 公众号第三方应用
-
-
Constructor Summary
Constructors Constructor Description WeixinComponentProxy()微信第三方组件接口实现(使用weixin4j.properties配置的account#components账号信息, 使用FileCacheStorager文件方式缓存TOKEN)WeixinComponentProxy(CacheStorager<Token> cacheStorager)微信第三方组件接口实现(使用weixin4j.properties配置的account#components账号信息)WeixinComponentProxy(WeixinMpAccount weixinMpAccount, CacheStorager<Token> cacheStorager)微信第三方组件接口实现
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcacheComponentTicket(String componentId, String componentTicket)缓存组件ticketComponentApicomponent()获取组接口对象(只关注第一个组件ComponentApicomponent(String componentId)获取套件接口对象(多个组件StringgetComponentAuthorizationURL(String componentId)应用组件授权 需先缓存ticket redirectUri默认填写weixin4j.properties#component.oauth.redirect.uri state默认填写stateStringgetComponentAuthorizationURL(String componentId, String redirectUri, String state)应用组件授权 需先缓存ticket,在授权完成之后需要调用ComponentApi# exchangeAuthorizerToken方法 ,否则无法缓存token相关导致后续的组件接口调用失败StringgetPreComponentTicket(String componentId)获取组件的预授权码 需先缓存ticketWeixinMpAccountgetWeixinMpAccount()获取微信账号信息WeixinProxygetWeixinProxy(String componentId, String authAppId)创建WeixinProxy对象
-
-
-
Field Detail
-
VERSION
public static final String VERSION
-
-
Constructor Detail
-
WeixinComponentProxy
public WeixinComponentProxy()
微信第三方组件接口实现(使用weixin4j.properties配置的account#components账号信息, 使用FileCacheStorager文件方式缓存TOKEN)
-
WeixinComponentProxy
public WeixinComponentProxy(CacheStorager<Token> cacheStorager)
微信第三方组件接口实现(使用weixin4j.properties配置的account#components账号信息)- Parameters:
cacheStorager- token管理
-
WeixinComponentProxy
public WeixinComponentProxy(WeixinMpAccount weixinMpAccount, CacheStorager<Token> cacheStorager)
微信第三方组件接口实现- Parameters:
weixinMpAccount- 账号信息cacheStorager- token管理
-
-
Method Detail
-
getWeixinMpAccount
public WeixinMpAccount getWeixinMpAccount()
获取微信账号信息- Returns:
-
component
public ComponentApi component()
获取组接口对象(只关注第一个组件- Returns:
- API实例
- See Also:
ComponentApi
-
component
public ComponentApi component(String componentId)
获取套件接口对象(多个组件- Parameters:
componentId- 组件ID- Returns:
- API实例
- See Also:
ComponentApi
-
getPreComponentTicket
public String getPreComponentTicket(String componentId) throws WeixinException
获取组件的预授权码 需先缓存ticket- Parameters:
componentId- 组件ID- Returns:
- 预授权码
- Throws:
WeixinException- See Also:
cacheComponentTicket(String, String),ComponentApi,ComponentApi.getTicketManager(),ComponentApi.getPreCodeManager()
-
cacheComponentTicket
public void cacheComponentTicket(String componentId, String componentTicket) throws WeixinException
缓存组件ticket- Parameters:
componentId- 组件IDcomponentTicket- 组件ticket内容- Throws:
WeixinException
-
getComponentAuthorizationURL
public String getComponentAuthorizationURL(String componentId) throws WeixinException
应用组件授权 需先缓存ticket- redirectUri默认填写weixin4j.properties#component.oauth.redirect.uri
- state默认填写state
- Parameters:
componentId- 组件ID- Returns:
- 请求授权的URL
- Throws:
WeixinException
-
getComponentAuthorizationURL
public String getComponentAuthorizationURL(String componentId, String redirectUri, String state) throws WeixinException
应用组件授权 需先缓存ticket,在授权完成之后需要调用ComponentApi# exchangeAuthorizerToken方法 ,否则无法缓存token相关导致后续的组件接口调用失败- Parameters:
componentId- 组件IDredirectUri- 授权后重定向urlstate- 回调后原样返回- Returns:
- 请求授权的URL
- Throws:
WeixinException- See Also:
cacheComponentTicket(String, String),ComponentApi,ComponentApi.getTicketManager(),ComponentApi.getPreCodeManager(),ComponentApi.exchangeAuthorizerToken(String), 应用组件授权
-
getWeixinProxy
public WeixinProxy getWeixinProxy(String componentId, String authAppId)
创建WeixinProxy对象- Parameters:
componentId- 组件IDauthAppId- 已授权的appid- Returns:
- See Also:
WeixinProxy
-
-