public function sendMessageTest()
{
include(ROOT_PATH. 'vendor' . DS . 'weworkapi_php-master'. DS . 'callback'. DS . "WXBizMsgCrypt.php") ;
$encodingAesKey = "J0KQdPFBqMUqg9a7VsOStPxgPCHNiQFkDExdlzgocbd";
$token = "kWzIUo0nPPN62tPHfWKpVcdORbmKE4f";
$corpId = "ww07ee28d63a4ce652";
$agentid = 1000002;
$sReqMsgSig = "457872467db8abb2ca554413ce82037b50ead437";
$sReqTimeStamp = "1676963539";
$sReqNonce = "1677569330";
$sReqData = "<xml><ToUserName><![CDATA[ww07ee28d63a4ce652]]></ToUserName><Encrypt><![CDATA[cwZU2H5qJeb65R/LQKCmWDIryDo1DwdUnvib/AJAiqVsemmUVcFxkP3mu2k0761gm2do5dHwe3sBCFhIjVF/oHuoyqnCoQW9oyWcIbmK9sLpQzp5fhfLmQ9nxb3rauTxroTwahuZ37nNp12ttiVwR7QajNzK5thkLLrezErVJgPpBiTRIESbXNIlWTDIwbk40szcwPn3v08DPAkvXLPqobRXo2Csrs7+b4cM1IQCLzTlFIJV6SqcfeikjfjNYp7Rcli1k/kiCclobgNvVOJZCyE3n2NzQffbSF3QVSMTSQjMGy8CLtvJPE5nzvcMhV4YnL4QhO87FNwDDbo2HVSpgqrks+Mvx+XlGEQgKakJ6mg9ElVlMeuQsGDfgo4oXw05EjlTq1IKCt8dPMc+9Sk96As6z3fcVcz1smrzLur5GSCkLvUFMhb9KnynVL+C6BUXyV8SvdM1AWwE7//Nd8M9Jw==]]></Encrypt><AgentID><![CDATA[1000002]]></AgentID></xml>";
$sMsg = "";
$wxcpt = new \WXBizMsgCrypt($token, $encodingAesKey, $corpId);
$errCode = $wxcpt->DecryptMsg($sReqMsgSig, $sReqTimeStamp, $sReqNonce, $sReqData, $sMsg);
if ($errCode == 0) {
try {
$test = new \SimpleXMLElement($sMsg);
$sMsg = strval($test->Content);
$FromUserName = strval($test->FromUserName);
$CreateTime = strval($test->CreateTime);
$MsgId = strval($test->MsgId);
} catch (Exception $e) {
$Content = "错误!";
}
} else {
print("ERR: " . $errCode . "\n\n");
}
$sendText = $sMsg.'是什么';
$sRespData = "<xml>
<ToUserName><![CDATA[{$FromUserName}]]></ToUserName>
<FromUserName><![CDATA[{$corpId}]]></FromUserName>
<CreateTime>{$CreateTime}</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[{$sendText}]]></Content>
<MsgId>{$MsgId}</MsgId>
<AgentID>{$agentid}</AgentID>
</xml>";
$sEncryptMsg = "";
$errCode = $wxcpt->EncryptMsg($sRespData, $sReqTimeStamp, $sReqNonce, $sEncryptMsg);
if ($errCode == 0) {
var_dump($sEncryptMsg);
print($sMsg."done \n");
} else {
print("ERR: " . $errCode . "\n\n");
}
}
你好,企业微信的问题可以到企业微信开发者中心提问https://developers.weixin.qq.com/community/enterprisewechat/doc/000ccec93983d8c11b3dcd93b5b801