MessageTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php /*
  2. * Copyright (C) 2017 All rights reserved.
  3. *
  4. * @File MessageTest.php
  5. * @Brief
  6. * @Author abelzhu, abelzhu@tencent.com
  7. * @Version 1.0
  8. * @Date 2017-12-26
  9. *
  10. */
  11. include_once("../src/CorpAPI.class.php");
  12. include_once("../src/ServiceCorpAPI.class.php");
  13. include_once("../src/ServiceProviderAPI.class.php");
  14. //
  15. $config = require('./config.php');
  16. //
  17. $agentId = $config['APP_ID'];
  18. $api = new CorpAPI($config['CORP_ID'], $config['APP_SECRET']);
  19. try {
  20. //
  21. $message = new Message();
  22. {
  23. $message->sendToAll = false;
  24. $message->touser = array("abelzhu", "ShengbenZhu");
  25. $message->toparty = array(1, 2, 1111, 3333);
  26. $message->totag= array(3, 4, 22233332, 33334444);
  27. $message->agentid = $agentId;
  28. $message->safe = 0;
  29. $message->messageContent = new NewsMessageContent(
  30. array(
  31. new NewsArticle(
  32. $title = "Got you !",
  33. $description = "Who's this cute guy testing me ?",
  34. $url = "https://work.weixin.qq.com/wework_admin/ww_mt/agenda",
  35. $picurl = "https://p.qpic.cn/pic_wework/167386225/f9ffc8f0a34f301580daaf05f225723ff571679f07e69f91/0",
  36. $btntxt = "btntxt"
  37. ),
  38. )
  39. );
  40. }
  41. $invalidUserIdList = null;
  42. $invalidPartyIdList = null;
  43. $invalidTagIdList = null;
  44. $api->MessageSend($message, $invalidUserIdList, $invalidPartyIdList, $invalidTagIdList);
  45. var_dump($invalidUserIdList);
  46. var_dump($invalidPartyIdList);
  47. var_dump($invalidTagIdList);
  48. } catch (Exception $e) {
  49. echo $e->getMessage() . "\n";
  50. }