Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
feat(douyin): ✨ 互动管理:获取评论列表、获取评论回复列表
Browse files Browse the repository at this point in the history
互动管理:获取评论列表、获取评论回复列表
  • Loading branch information
waset authored Apr 23, 2022
1 parent 74922e4 commit 84b4e15
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/Douyin/Item.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace Waset\Douyin;

class Item extends Application
{
/**
* 获取评论列表
*
* @param string $access_token
* @param string $openid 用户唯一标志
* @param string $item_id 视频id
* @param integer $cursor 分页游标
* @param integer $count 每页的数量,最大不超过50,最小不低于1
* @param string $sort_type 列表排序方式,不传默认按推荐序,可选值:time(时间逆序)、time_asc(时间顺序)
* @return Item
*/
public function comments(string $access_token, string $openid, string $item_id, int $cursor = 0, int $count = 20, string $sort_type = '')
{
$api_url = self::BaseUrl . '/item/comment/list/';

$headers = [
"access-token: ${access_token}",
'Content-Type: application/json',
];
$params = [
'open_id' => $openid,
"cursor" => $cursor,
"count" => $count,
"item_id" => $item_id,
"sort_type" => $sort_type,
];

$res = $this->https_get($api_url, $params, $headers)->toArray();

return $res['data'];
}

/**
* 获取评论回复列表
*
* @param string $access_token
* @param string $openid 用户唯一标志
* @param string $item_id 视频id
* @param integer $cursor 分页游标
* @param integer $count 每页的数量,最大不超过50,最小不低于1
* @param string $sort_type 列表排序方式,不传默认按推荐序,可选值:time(时间逆序)、time_asc(时间顺序)
* @return Item
*/
public function replys(string $access_token, string $openid, string $item_id,string $comment_id, int $cursor = 0, int $count = 20, string $sort_type = '')
{
$api_url = self::BaseUrl . '/item/comment/reply/list/';

$headers = [
"access-token: ${access_token}",
'Content-Type: application/json',
];
$params = [
'open_id' => $openid,
"cursor" => $cursor,
"count" => $count,
"item_id" => $item_id,
"comment_id"=> $comment_id,
"sort_type" => $sort_type,
];

$res = $this->https_get($api_url, $params, $headers)->toArray();

return $res['data'];
}
}

0 comments on commit 84b4e15

Please sign in to comment.