com.foxinmy.weixin4j.mp
Class WeixinComponentProxy

java.lang.Object
  extended by com.foxinmy.weixin4j.mp.WeixinComponentProxy

public class WeixinComponentProxy
extends Object

微信第三方应用接口实现

Since:
JDK 1.6
Author:
jinyu(foxinmy@gmail.com)
See Also:
ComponentApi, 公众号第三方应用

Field Summary
static String VERSION
           
 
Constructor Summary
WeixinComponentProxy()
          微信第三方组件接口实现(使用weixin4j.properties配置的account#components账号信息, 使用FileCacheStorager文件方式缓存TOKEN)
WeixinComponentProxy(CacheStorager<Token> cacheStorager)
          微信第三方组件接口实现(使用weixin4j.properties配置的account#components账号信息)
WeixinComponentProxy(WeixinMpAccount weixinMpAccount, CacheStorager<Token> cacheStorager)
          微信第三方组件接口实现
 
Method Summary
 void cacheComponentTicket(String componentId, String componentTicket)
          缓存组件ticket
 ComponentApi component()
          获取组接口对象(只关注第一个组件
 ComponentApi component(String componentId)
          获取套件接口对象(多个组件
 String getComponentAuthorizationURL(String componentId)
          应用组件授权 需先缓存ticket redirectUri默认填写weixin4j.properties#component.oauth.redirect.uri state默认填写state
 String getComponentAuthorizationURL(String componentId, String redirectUri, String state)
          应用组件授权 需先缓存ticket,在授权完成之后需要调用ComponentApi#exchangeAuthInfo方法 ,否则无法缓存token相关导致后续的组件接口调用失败
 String getPreComponentTicket(String componentId)
          获取组件的预授权码 需先缓存ticket
 WeixinMpAccount getWeixinMpAccount()
          获取微信账号信息
 WeixinProxy getWeixinProxy(String componentId, String authAppId)
          创建WeixinProxy对象
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
See Also:
Constant Field Values
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 - 组件ID
componentTicket - 组件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
    See Also:
    #getComponentAuthorizationURL(String, String,String)}

  • getComponentAuthorizationURL

    public String getComponentAuthorizationURL(String componentId,
                                               String redirectUri,
                                               String state)
                                        throws WeixinException
    应用组件授权 需先缓存ticket,在授权完成之后需要调用ComponentApi#exchangeAuthInfo方法 ,否则无法缓存token相关导致后续的组件接口调用失败

    Parameters:
    componentId - 组件ID
    redirectUri - 授权后重定向url
    state - 回调后原样返回
    Returns:
    请求授权的URL
    Throws:
    WeixinException
    See Also:
    cacheComponentTicket(String, String), ComponentApi, ComponentApi.getTicketManager(), ComponentApi.getPreCodeManager(), ComponentApi.exchangeAuthInfo(String), 应用组件授权

    getWeixinProxy

    public WeixinProxy getWeixinProxy(String componentId,
                                      String authAppId)
    创建WeixinProxy对象

    Parameters:
    componentId - 组件ID
    authAppId - 已授权的appid
    Returns:
    See Also:
    WeixinProxy


    Copyright © 2014–2017. All rights reserved.