demo.php 559 B

1234567891011121314151617181920
  1. <?php
  2. include "wechat.class.php";
  3. $options = array(
  4. 'token'=>'tokenaccesskey' //填写你设定的key
  5. );
  6. $weObj = new Wechat($options);
  7. $weObj->valid();//明文或兼容模式可以在接口验证通过后注释此句,但加密模式一定不能注释,否则会验证失败
  8. $type = $weObj->getRev()->getRevType();
  9. switch($type) {
  10. case Wechat::MSGTYPE_TEXT:
  11. $weObj->text("hello, I'm wechat")->reply();
  12. exit;
  13. break;
  14. case Wechat::MSGTYPE_EVENT:
  15. break;
  16. case Wechat::MSGTYPE_IMAGE:
  17. break;
  18. default:
  19. $weObj->text("help info")->reply();
  20. }