Message.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2023 ThinkAdmin [ thinkadmin.top ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免责声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
  13. // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
  14. // +----------------------------------------------------------------------
  15. namespace WeMini;
  16. use WeChat\Contracts\BasicWeChat;
  17. /**
  18. * 小程序动态消息
  19. * Class Message
  20. * @package WeMini
  21. */
  22. class Message extends BasicWeChat
  23. {
  24. /**
  25. * 动态消息,创建被分享动态消息的 activity_id
  26. * @param array $data
  27. * @return array
  28. * @throws \WeChat\Exceptions\InvalidResponseException
  29. * @throws \WeChat\Exceptions\LocalCacheException
  30. */
  31. public function createActivityId($data)
  32. {
  33. $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/activityid/create?access_token=ACCESS_TOKEN';
  34. return $this->callPostApi($url, $data, true);
  35. }
  36. /**
  37. * 动态消息,修改被分享的动态消息
  38. * @param array $data
  39. * @return array
  40. * @throws \WeChat\Exceptions\InvalidResponseException
  41. * @throws \WeChat\Exceptions\LocalCacheException
  42. */
  43. public function setUpdatableMsg($data)
  44. {
  45. $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/updatablemsg/send?access_token=ACCESS_TOKEN';
  46. return $this->callPostApi($url, $data, true);
  47. }
  48. /**
  49. * 下发小程序和公众号统一的服务消息
  50. * @param array $data
  51. * @return array
  52. * @throws \WeChat\Exceptions\InvalidResponseException
  53. * @throws \WeChat\Exceptions\LocalCacheException
  54. */
  55. public function uniformSend($data)
  56. {
  57. $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN';
  58. return $this->callPostApi($url, $data, true);
  59. }
  60. }