Client.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * This file is part of the apiadmin/tiktok.
  4. */
  5. namespace App\Libs\TikTok\OpenPlatform\VideoData;
  6. use App\Libs\TikTok\Kernel\BaseClient;
  7. use App\Libs\TikTok\Kernel\Exceptions\HttpException;
  8. use App\Libs\TikTok\Kernel\Exceptions\InvalidConfigException;
  9. use App\Libs\TikTok\Kernel\Support\Collection;
  10. use GuzzleHttp\Exception\GuzzleException;
  11. use Psr\Http\Message\ResponseInterface;
  12. /**
  13. * Class Client.
  14. *
  15. * @author zhaoxiang <zhaoxiang051405@gmail.com>
  16. */
  17. class Client extends BaseClient {
  18. protected $postAccessToken = false;
  19. /**
  20. * 获取视频基础数据
  21. * @param string $item
  22. * @return array|Collection|object|ResponseInterface|string
  23. * @throws HttpException
  24. * @throws InvalidConfigException
  25. * @throws GuzzleException
  26. */
  27. public function base(string $item) {
  28. return $this->httpGet('data/external/item/base/', ['item_id' => $item]);
  29. }
  30. /**
  31. * 获取视频点赞数
  32. * @param string $item
  33. * @param int $date_type
  34. * @return array|Collection|object|ResponseInterface|string
  35. * @throws GuzzleException
  36. * @throws HttpException
  37. * @throws InvalidConfigException
  38. */
  39. public function like(string $item, int $date_type = 7) {
  40. return $this->httpGet('data/external/item/like/', ['item_id' => $item, 'date_type' => $date_type]);
  41. }
  42. /**
  43. * 获取视频评论数
  44. * @param string $item
  45. * @param int $date_type
  46. * @return array|Collection|object|ResponseInterface|string
  47. * @throws GuzzleException
  48. * @throws HttpException
  49. * @throws InvalidConfigException
  50. */
  51. public function comment(string $item, int $date_type = 7) {
  52. return $this->httpGet('data/external/item/comment/', ['item_id' => $item, 'date_type' => $date_type]);
  53. }
  54. /**
  55. * 获取视频分享数
  56. * @param string $item
  57. * @param int $date_type
  58. * @return array|Collection|object|ResponseInterface|string
  59. * @throws GuzzleException
  60. * @throws HttpException
  61. * @throws InvalidConfigException
  62. */
  63. public function share(string $item, int $date_type = 7) {
  64. return $this->httpGet('data/external/item/share/', ['item_id' => $item, 'date_type' => $date_type]);
  65. }
  66. /**
  67. * 获取视频播放数
  68. * @param string $item
  69. * @param int $date_type
  70. * @return array|Collection|object|ResponseInterface|string
  71. * @throws GuzzleException
  72. * @throws HttpException
  73. * @throws InvalidConfigException
  74. */
  75. public function play(string $item, int $date_type = 7) {
  76. return $this->httpGet('data/external/item/play/', ['item_id' => $item, 'date_type' => $date_type]);
  77. }
  78. }