List comments by post
This commit is contained in:
parent
620553ea14
commit
d889fdff20
3 changed files with 33 additions and 17 deletions
|
|
@ -1 +1,2 @@
|
|||
from .create import create
|
||||
from .listtbypostid import listtbypostid
|
||||
12
jobs/comment/listtbypostid.py
Normal file
12
jobs/comment/listtbypostid.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
def listtbypostid(API, post_id: str,) -> dict:
|
||||
"""
|
||||
Fetches the list of comments for a given post ID from the API.
|
||||
|
||||
Args:
|
||||
post_id (str): ID of the post to fetch comments for.
|
||||
Returns:
|
||||
dict: The list of comments for the post.
|
||||
"""
|
||||
print(f"Fetching comments for post ID: {post_id}")
|
||||
comment_list = API.make_request("GET", "content", f"comment/bypostid/{post_id}", authenticate=True)
|
||||
return comment_list
|
||||
35
testing.py
35
testing.py
|
|
@ -38,7 +38,7 @@ if not API.is_token_valid():
|
|||
# branch = API.run_job('branch.get', "music")
|
||||
# print(branch)
|
||||
# print("-------------- Get a post -------------------")
|
||||
# post = API.run_job('post.get', "1774875037-170a46a9")
|
||||
# post = API.run_job('post.get', "1774951384-98fe38df")
|
||||
# print(post)
|
||||
# print("-----------------------------")
|
||||
# feed = API.run_job('post.listbybranch', "music")
|
||||
|
|
@ -59,18 +59,21 @@ if not API.is_token_valid():
|
|||
# })
|
||||
# print(post)
|
||||
# print("-----------------------------")
|
||||
post = API.run_job('comment.create', {
|
||||
"blurLabel": None,
|
||||
"commentText": "This is a test comment created via the API wrapper.",
|
||||
"parent": {
|
||||
"pk": "maintrunk#maintrunk",
|
||||
"sk": "post#1774951384-98fe38df",
|
||||
"slug": "1774951384-98fe38df"
|
||||
},
|
||||
"topLevel": {
|
||||
"pk": "maintrunk#maintrunk",
|
||||
"sk": "post#1774951384-98fe38df"
|
||||
},
|
||||
"version": 3
|
||||
})
|
||||
print(post)
|
||||
# post = API.run_job('comment.create', {
|
||||
# "blurLabel": None,
|
||||
# "commentText": "This is a test comment created via the API wrapper.",
|
||||
# "parent": {
|
||||
# "pk": "maintrunk#maintrunk",
|
||||
# "sk": "post#1774951384-98fe38df",
|
||||
# "slug": "1774951384-98fe38df"
|
||||
# },
|
||||
# "topLevel": {
|
||||
# "pk": "maintrunk#maintrunk",
|
||||
# "sk": "post#1774951384-98fe38df"
|
||||
# },
|
||||
# "version": 3
|
||||
# })
|
||||
# print(post)
|
||||
# print("-----------------------------")
|
||||
feed = API.run_job('comment.listtbypostid', "1774951384-98fe38df")
|
||||
print(feed)
|
||||
Loading…
Add table
Add a link
Reference in a new issue