test1.php 642 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * 微信公共接口测试
  4. *
  5. */
  6. include("../wechat.class.php");
  7. function logdebug($text){
  8. file_put_contents('../data/log.txt',$text."\n",FILE_APPEND);
  9. };
  10. $options = array(
  11. 'token'=>'tokenaccesskey', //填写你设定的key
  12. 'debug'=>true,
  13. 'logcallback'=>'logdebug'
  14. );
  15. $weObj = new Wechat($options);
  16. $weObj->valid();
  17. $type = $weObj->getRev()->getRevType();
  18. switch($type) {
  19. case Wechat::MSGTYPE_TEXT:
  20. $weObj->text("hello, I'm wechat")->reply();
  21. exit;
  22. break;
  23. case Wechat::MSGTYPE_EVENT:
  24. break;
  25. case Wechat::MSGTYPE_IMAGE:
  26. break;
  27. default:
  28. $weObj->text("help info")->reply();
  29. }