PHP Class PFinal\Wechat\Api

Since: 1.0
Author: Zou Yiliang
Datei anzeigen Open project: pfinal/wechat Class Usage Examples

Protected Properties

Property Type Description
$accessToken
$appId
$appSecret
$encodingAesKey
$encodingAesKeyLast
$middleUrl
$token

Public Methods

Method Description
__construct ( array | string $appId, string | null $appSecret = null, string | null $token = null, string | null $encodingAesKey = null, string | null $encodingAesKeyLast = null, $middleUrl = null ) 构造方法 可以使用一个数组作为参数
buildReply ( mixed $reply ) : string 构造响应xml字符串,用于微信服务器请求时被动响应
checkSignature ( ) : boolean 验证请求是否来自微信公共平台
getAccessToken ( boolean $useCache = true ) : string | null 获取公众号的全局唯一票据accessToken,公众号主动调用各接口时都需使用accessToken accessToken默认有效时间为7200秒,每天调用次数有限制,认证服务号每天最多100000次
getAppId ( ) : string 返回appId
getAppSecret ( ) : string 返回appSecret
getMessage ( ) : Receive 返回消息对象,字段大小写与开放平台文档一致
getMiddleUrl ( ) : string | null
setAccessToken ( string $accessToken ) 设置AccessToken

Protected Methods

Method Description
attemptDecrypt ( string $message ) : string 尝试解密数据,从$_GET['encrypt_type']中获取加密类型,如果未加密,原样返回
attemptEncrypt ( string $message ) : string 对响应给微信服务器的消息进行加密,自动识别是否需要加密,本次请求未加密时,数据原样返回
decryptMsg ( string $msgSignature, string $timestamp, string $nonce, string $encryptMsg ) : string 解密
encryptMsg ( $replyMsg, $timestamp, $nonce ) : string 解密

Method Details

__construct() public method

构造方法 可以使用一个数组作为参数
public __construct ( array | string $appId, string | null $appSecret = null, string | null $token = null, string | null $encodingAesKey = null, string | null $encodingAesKeyLast = null, $middleUrl = null )
$appId array | string
$appSecret string | null
$token string | null
$encodingAesKey string | null
$encodingAesKeyLast string | null

attemptDecrypt() protected method

尝试解密数据,从$_GET['encrypt_type']中获取加密类型,如果未加密,原样返回
protected attemptDecrypt ( string $message ) : string
$message string
return string

attemptEncrypt() protected method

对响应给微信服务器的消息进行加密,自动识别是否需要加密,本次请求未加密时,数据原样返回
protected attemptEncrypt ( string $message ) : string
$message string
return string

buildReply() public method

构造响应xml字符串,用于微信服务器请求时被动响应
public buildReply ( mixed $reply ) : string
$reply mixed 被动响应的内容,ReplyMessage对象,News数组 或string
return string

checkSignature() public method

验证请求是否来自微信公共平台
public checkSignature ( ) : boolean
return boolean

decryptMsg() protected method

解密
protected decryptMsg ( string $msgSignature, string $timestamp, string $nonce, string $encryptMsg ) : string
$msgSignature string
$timestamp string
$nonce string
$encryptMsg string
return string

encryptMsg() protected method

解密
protected encryptMsg ( $replyMsg, $timestamp, $nonce ) : string
$replyMsg
$timestamp
$nonce
return string

getAccessToken() public method

获取公众号的全局唯一票据accessToken,公众号主动调用各接口时都需使用accessToken accessToken默认有效时间为7200秒,每天调用次数有限制,认证服务号每天最多100000次
public getAccessToken ( boolean $useCache = true ) : string | null
$useCache boolean 是否使用缓存
return string | null

getAppId() public method

返回appId
public getAppId ( ) : string
return string

getAppSecret() public method

返回appSecret
public getAppSecret ( ) : string
return string

getMessage() public method

返回消息对象,字段大小写与开放平台文档一致
public getMessage ( ) : Receive
return PFinal\Wechat\Message\Receive

getMiddleUrl() public method

public getMiddleUrl ( ) : string | null
return string | null

setAccessToken() public method

设置AccessToken
public setAccessToken ( string $accessToken )
$accessToken string

Property Details

$accessToken protected_oe property

protected $accessToken

$appId protected_oe property

protected $appId

$appSecret protected_oe property

protected $appSecret

$encodingAesKey protected_oe property

protected $encodingAesKey

$encodingAesKeyLast protected_oe property

protected $encodingAesKeyLast

$middleUrl protected_oe property

protected $middleUrl

$token protected_oe property

protected $token