Forum Discussion

Jk07's avatar
Jk07
Adept
12 months ago

Show Recent Posts, Most Kudoed Posts and Most Viewed Posts.

How to get Most Recent Posts, most kudoed Posts and Most viewed Posts using V1 and V2 call.
  • AmanMalhotra's avatar
    12 months ago

    Hi Jk07 ,

    Below are the APIs available in APIv2 below, Khoros always recommends using APIv2 as we can fetch specific fields required with APIv2 irrespective of APIv1:

    Most Recent Posts APIv2
    select * from messages 
    ORDER BY post_time DESC
    ~~other variation with more fields and options:
    select 
    id, tags, labels, conversation.solved, conversation.last_post_time, conversation.last_post_time_friendly, user_context.read, images, board.id, board.title, board.view_href, teaser, body, post_time_friendly, subject, author.login, author.view_href, author.avatar.profile, author.rank.name, author.rank.color, author.rank.bold, post_time, view_href, kudos.sum(weight), replies.count(*), metrics.views, conversation.solved from messages where conversation.style = "forum" and depth=0 ORDER BY post_time DESC limit 999 offset 0

    Most Kudoed Posts APIv2
    select * from messages ORDER BY kudos.sum(weight) DESC
    ~~other variation with more fields and options:
    select id, tags, labels, conversation.solved, conversation.last_post_time, conversation.last_post_time_friendly, user_context.read, images, board.id, board.title, board.view_href, teaser, body, post_time_friendly, subject, author.login, author.view_href, author.avatar.profile, author.rank.name, author.rank.color, author.rank.bold, post_time, view_href, kudos.sum(weight), replies.count(*), metrics.views, conversation.solved from messages where conversation.style = "forum" and depth=0 ORDER BY kudos.sum(weight) DESC limit 999 offset 0

    Most Viewed Posts APIv2
    select * from messages ORDER BY metrics.views DESC
    ~~other variation with more fields and options:
    select id, tags, labels, conversation.solved, conversation.last_post_time, conversation.last_post_time_friendly, user_context.read, images, board.id, board.title, board.view_href, teaser, body, post_time_friendly, subject, author.login, author.view_href, author.avatar.profile, author.rank.name, author.rank.color, author.rank.bold, post_time, view_href, kudos.sum(weight), replies.count(*), metrics.views, conversation.solved from messages where conversation.style = "forum" and depth=0 ORDER BY metrics.views DESC limit 999 offset 0

    Please give me Kudos if you think my post is helpful
    and Accept as Solution if this answers your query