Scheme.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace WeMini;
  3. use WeChat\Contracts\BasicWeChat;
  4. /**
  5. * 小程序 URL-Scheme
  6. * Class Scheme
  7. * @package WeMini
  8. */
  9. class Scheme extends BasicWeChat
  10. {
  11. /**
  12. * 创建 URL-Scheme
  13. * @param array $data
  14. * @return array
  15. * @throws \WeChat\Exceptions\InvalidResponseException
  16. * @throws \WeChat\Exceptions\LocalCacheException
  17. */
  18. public function create($data)
  19. {
  20. $url = 'https://api.weixin.qq.com/wxa/generatescheme?access_token=ACCESS_TOKEN';
  21. return $this->callPostApi($url, $data, true);
  22. }
  23. /**
  24. * 查询 URL-Scheme
  25. * @param string $scheme
  26. * @return array
  27. * @throws \WeChat\Exceptions\InvalidResponseException
  28. * @throws \WeChat\Exceptions\LocalCacheException
  29. */
  30. public function query($scheme)
  31. {
  32. $url = 'https://api.weixin.qq.com/wxa/queryscheme?access_token=ACCESS_TOKEN';
  33. return $this->callPostApi($url, ['scheme' => $scheme], true);
  34. }
  35. /**
  36. * 创建 URL-Link
  37. * @param array $data
  38. * @return array
  39. * @throws \WeChat\Exceptions\InvalidResponseException
  40. * @throws \WeChat\Exceptions\LocalCacheException
  41. */
  42. public function urlLink($data)
  43. {
  44. $url = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=ACCESS_TOKEN";
  45. return $this->callPostApi($url, $data, true);
  46. }
  47. /**
  48. * 查询 URL-Link
  49. * @param string $urllink
  50. * @return array
  51. * @throws \WeChat\Exceptions\InvalidResponseException
  52. * @throws \WeChat\Exceptions\LocalCacheException
  53. */
  54. public function urlQuery($urllink)
  55. {
  56. $url = 'https://api.weixin.qq.com/wxa/query_urllink?access_token=ACCESS_TOKEN';
  57. return $this->callPostApi($url, ['url_link' => $urllink], true);
  58. }
  59. }