ShakeAround.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <?php
  2. /*
  3. * This file is part of the overtrue/wechat.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. /**
  11. * ShakeAround.php.
  12. *
  13. * @author allen05ren <allen05ren@outlook.com>
  14. * @copyright 2016 overtrue <i@overtrue.me>
  15. *
  16. * @see https://github.com/overtrue
  17. * @see http://overtrue.me
  18. */
  19. namespace EasyWeChat\ShakeAround;
  20. use EasyWeChat\Core\AbstractAPI;
  21. /**
  22. * Class ShakeAround.
  23. */
  24. class ShakeAround extends AbstractAPI
  25. {
  26. const API_ACCOUNT_REGISTER = 'https://api.weixin.qq.com/shakearound/account/register';
  27. const API_ACCOUNT_AUDIT_STATUS = 'https://api.weixin.qq.com/shakearound/account/auditstatus';
  28. const API_GET_SHAKE_INFO = 'https://api.weixin.qq.com/shakearound/user/getshakeinfo';
  29. /**
  30. * Device instance.
  31. *
  32. * @var \EasyWeChat\ShakeAround\Device
  33. */
  34. protected $device = null;
  35. /**
  36. * Group instance.
  37. *
  38. * @var \EasyWeChat\ShakeAround\Group
  39. */
  40. protected $group = null;
  41. /**
  42. * Page instance.
  43. *
  44. * @var \EasyWeChat\ShakeAround\Page
  45. */
  46. protected $page = null;
  47. /**
  48. * Material instance.
  49. *
  50. * @var \EasyWeChat\ShakeAround\Material
  51. */
  52. protected $material = null;
  53. /**
  54. * Relation instance.
  55. *
  56. * @var \EasyWeChat\ShakeAround\Relation
  57. */
  58. protected $relation = null;
  59. /**
  60. * Stats instance.
  61. *
  62. * @var \EasyWeChat\ShakeAround\Stats
  63. */
  64. protected $stats = null;
  65. /**
  66. * Register shake around.
  67. *
  68. * @param string $name
  69. * @param string $tel
  70. * @param string $email
  71. * @param string $industryId
  72. * @param array $certUrls
  73. * @param string $reason
  74. *
  75. * @return \EasyWeChat\Support\Collection
  76. */
  77. public function register($name, $tel, $email, $industryId, array $certUrls, $reason = '')
  78. {
  79. $params = [
  80. 'name' => $name,
  81. 'phone_number' => strval($tel),
  82. 'email' => $email,
  83. 'industry_id' => $industryId,
  84. 'qualification_cert_urls' => $certUrls,
  85. ];
  86. if ('' !== $reason) {
  87. $params['apply_reason'] = $reason;
  88. }
  89. return $this->parseJSON('json', [self::API_ACCOUNT_REGISTER, $params]);
  90. }
  91. /**
  92. * Get audit status.
  93. *
  94. * @return \EasyWeChat\Support\Collection
  95. */
  96. public function getStatus()
  97. {
  98. return $this->parseJSON('get', [self::API_ACCOUNT_AUDIT_STATUS]);
  99. }
  100. /**
  101. * Get shake info.
  102. *
  103. * @param string $ticket
  104. * @param int $needPoi
  105. *
  106. * @return \EasyWeChat\Support\Collection
  107. */
  108. public function getShakeInfo($ticket, $needPoi = null)
  109. {
  110. $params = [
  111. 'ticket' => $ticket,
  112. ];
  113. if (null !== $needPoi) {
  114. $params['need_poi'] = intval($needPoi);
  115. }
  116. return $this->parseJSON('json', [self::API_GET_SHAKE_INFO, $params]);
  117. }
  118. /**
  119. * Return the device instance.
  120. *
  121. * @return \EasyWeChat\ShakeAround\Device
  122. */
  123. public function device()
  124. {
  125. if (is_null($this->device)) {
  126. $this->device = new Device($this->accessToken);
  127. }
  128. return $this->device;
  129. }
  130. /**
  131. * Return the group instance.
  132. *
  133. * @return \EasyWeChat\ShakeAround\Group
  134. */
  135. public function group()
  136. {
  137. if (is_null($this->group)) {
  138. $this->group = new Group($this->accessToken);
  139. }
  140. return $this->group;
  141. }
  142. /**
  143. * Return the page instance.
  144. *
  145. * @return \EasyWeChat\ShakeAround\Page
  146. */
  147. public function page()
  148. {
  149. if (is_null($this->page)) {
  150. $this->page = new Page($this->accessToken);
  151. }
  152. return $this->page;
  153. }
  154. /**
  155. * Return the material instance.
  156. *
  157. * @return \EasyWeChat\ShakeAround\Material
  158. */
  159. public function material()
  160. {
  161. if (is_null($this->material)) {
  162. $this->material = new Material($this->accessToken);
  163. }
  164. return $this->material;
  165. }
  166. /**
  167. * Return the relation instance.
  168. *
  169. * @return \EasyWeChat\ShakeAround\Relation
  170. */
  171. public function relation()
  172. {
  173. if (is_null($this->relation)) {
  174. $this->relation = new Relation($this->accessToken);
  175. }
  176. return $this->relation;
  177. }
  178. /**
  179. * Return the stats instance.
  180. *
  181. * @return \EasyWeChat\ShakeAround\Stats
  182. */
  183. public function stats()
  184. {
  185. if (is_null($this->stats)) {
  186. $this->stats = new Stats($this->accessToken);
  187. }
  188. return $this->stats;
  189. }
  190. }