com.foxinmy.weixin4j.model
Class Token

java.lang.Object
  extended by com.foxinmy.weixin4j.model.Token
All Implemented Interfaces:
Cacheable, Serializable

public class Token
extends Object
implements Cacheable

access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token,正常情况下access_token有效期为7200秒, 重复获取将导致上次获取的access_token失效

Since:
JDK 1.6
Author:
jinyu(foxinmy@gmail.com)
See Also:
微信公众平台获取token, 微信企业号的主动模式, Serialized Form

Constructor Summary
Token(String accessToken)
          永不过期、创建时间为当前时间戳的token对象
Token(String accessToken, long expires)
          有过期时间、创建时间为当前时间戳的token对象
Token(String accessToken, long expires, long createTime)
           
 
Method Summary
 String getAccessToken()
           
 long getCreateTime()
          创建时间(单位:毫秒)
 long getExpires()
          过期时间(单位:毫秒),值小于0时视为永不过期
 Map<String,String> getExtra()
           
 Token pushExtra(String name, String value)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Token

public Token(String accessToken)
永不过期、创建时间为当前时间戳的token对象

Parameters:
accessToken - 凭证字符串

Token

public Token(String accessToken,
             long expires)
有过期时间、创建时间为当前时间戳的token对象

Parameters:
accessToken - 凭证字符串
expires - 过期时间 单位毫秒

Token

public Token(String accessToken,
             long expires,
             long createTime)
Parameters:
accessToken - 凭证字符串
expires - 过期时间 单位毫秒
createTime - 创建时间戳 单位毫秒
Method Detail

getAccessToken

public String getAccessToken()

getExpires

public long getExpires()
Description copied from interface: Cacheable
过期时间(单位:毫秒),值小于0时视为永不过期

Specified by:
getExpires in interface Cacheable
Returns:
缓存过期时间

getCreateTime

public long getCreateTime()
Description copied from interface: Cacheable
创建时间(单位:毫秒)

Specified by:
getCreateTime in interface Cacheable
Returns:
缓存对象创建时间

getExtra

public Map<String,String> getExtra()

pushExtra

public Token pushExtra(String name,
                       String value)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014–2017. All rights reserved.