Overview

Packages

  • None
  • WxRobot
    • Admin
    • Cmd
    • CoreFunctions
    • Exends
    • Install
    • Table
    • Uninstall
    • WxSDK

Classes

  • ErrorCode
  • PKCS7Encoder
  • Prpcrypt
  • SHA1
  • Weixin_BaseCore
  • WeiXin_SDK
  • Weixin_Template
  • WXBizMsgCrypt
  • XMLParse
  • Overview
  • Package
  • Class

Class WXBizMsgCrypt

1.第三方回复加密消息给公众平台; 2.第三方收到公众平台发送的消息,验证消息的安全性,并对消息进行解密。

Copyright: Copyright (c) 1998-2014 Tencent Inc.
Located at weixin-sdk-api/weixin_crypt/wxBizMsgCrypt.php
Methods summary
public
# WXBizMsgCrypt( $token, $encodingAesKey, $appId )

构造函数

构造函数

Parameters

$token
公众平台上,开发者设置的token
$encodingAesKey
公众平台上,开发者设置的EncodingAESKey
$appId
公众平台的appId
public integer
# encryptMsg( $replyMsg, $timeStamp, $nonce, &$encryptMsg & $encryptMsg )

将公众平台回复用户的消息加密打包.

  1. 对要发送的消息进行AES-CBC加密
  2. 生成安全签名
  3. 将消息密文和安全签名打包成xml格式

将公众平台回复用户的消息加密打包.

  1. 对要发送的消息进行AES-CBC加密
  2. 生成安全签名
  3. 将消息密文和安全签名打包成xml格式

Parameters

$replyMsg
公众平台待回复用户的消息,xml格式的字符串
$timeStamp
时间戳,可以自己生成,也可以用URL参数的timestamp
$nonce
随机串,可以自己生成,也可以用URL参数的nonce
$encryptMsg

加密后的可以直接回复用户的密文,包括msg_signature, timestamp, nonce, encrypt的xml格式的字符串, 当return返回0时有效

Returns

integer
成功0,失败返回对应的错误码
public integer
# decryptMsg( $msgSignature, $timestamp, $nonce, $postData, &$msg & $msg )

检验消息的真实性,并且获取解密后的明文.

  1. 利用收到的密文生成安全签名,进行签名验证
  2. 若验证通过,则提取xml中的加密消息
  3. 对消息进行解密

检验消息的真实性,并且获取解密后的明文.

  1. 利用收到的密文生成安全签名,进行签名验证
  2. 若验证通过,则提取xml中的加密消息
  3. 对消息进行解密

Parameters

$msgSignature
签名串,对应URL参数的msg_signature
$timestamp
时间戳 对应URL参数的timestamp
$nonce
随机串,对应URL参数的nonce
$postData
密文,对应POST请求的数据
$msg
解密后的原文,当return返回0时有效

Returns

integer
成功0,失败返回对应的错误码
API documentation generated by ApiGen