Message.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://think.ctolog.com
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
  12. // +----------------------------------------------------------------------
  13. namespace WeMini;
  14. use WeChat\Contracts\BasicWeChat;
  15. /**
  16. * 小程序动态消息
  17. * Class Message
  18. * @package WeMini
  19. */
  20. class Message extends BasicWeChat
  21. {
  22. /**
  23. * 动态消息,创建被分享动态消息的 activity_id
  24. * @param array $data
  25. * @return array
  26. * @throws \WeChat\Exceptions\InvalidResponseException
  27. * @throws \WeChat\Exceptions\LocalCacheException
  28. */
  29. public function createActivityId($data)
  30. {
  31. $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/activityid/create?access_token=ACCESS_TOKEN';
  32. $this->registerApi($url, __FUNCTION__, func_get_args());
  33. return $this->callPostApi($url, $data, true);
  34. }
  35. /**
  36. * 动态消息,修改被分享的动态消息
  37. * @param array $data
  38. * @return array
  39. * @throws \WeChat\Exceptions\InvalidResponseException
  40. * @throws \WeChat\Exceptions\LocalCacheException
  41. */
  42. public function setUpdatableMsg($data)
  43. {
  44. $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/updatablemsg/send?access_token=ACCESS_TOKEN';
  45. $this->registerApi($url, __FUNCTION__, func_get_args());
  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. $this->registerApi($url, __FUNCTION__, func_get_args());
  59. return $this->callPostApi($url, $data, true);
  60. }
  61. }