CallBackVerify.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace weworkapi\receive;
  3. use weworkapi\receive\WXBizMsgCrypt;
  4. class CallBackVerify {
  5. public function index(){
  6. // 假设企业号在公众平台上设置的参数如下
  7. $encodingAesKey = "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C";
  8. $token = "QDG6eK";
  9. $receiveid = "wx5823bf96d3bd56c7";
  10. $wxcpt = new WXBizMsgCrypt($token, $encodingAesKey, $receiveid);
  11. // http://cq.xuduan.tech:62606/weworkapi_php/callback_json/callbackverify.php?msg_signature=5c45ff5e21c57e6ad56bac8758b79b1d9ac89fd3&timestamp=1409659589&nonce=263014780&echostr=P9nAzCzyDtyTWESHep1vC5X9xho%2FqYX3Zpb4yKa9SKld1DsH3Iyt3tP3zNdtp%2B4RPcs8TgAE7OaBO%2BFZXvnaqQ%3D%3D
  12. // sdk the paramters
  13. $sVerifyMsgSig = $_GET['msg_signature'];
  14. $sVerifyTimeStamp = $_GET['timestamp'];
  15. $sVerifyNonce = $_GET['nonce'];
  16. $sVerifyEchoStr = $_GET['echostr'];
  17. $sEchoStr = "";
  18. // call verify function
  19. $errCode = $wxcpt->VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr);
  20. if ($errCode == 0) {
  21. echo $sEchoStr . "\n";
  22. } else {
  23. print("ERR: " . $errCode . "\n\n");
  24. }
  25. }
  26. }
  27. ?>