Forum Discussion

keithkelly's avatar
3 years ago

API Help: Recent Topics (but only for subscribed boards?)

Our external beta users have requested a Recent Discussions module on the home page, but filtered to only discussions within their subscribed areas. 

I realize a My Subscriptions panel exists, but I'd like to use the message list within one of our fancypants custom components. 

SELECT yada, yoda FROM messages WHERE subscribed = 'I am'" />

 

 Do any of you happen to know the API call(s) to do this?

2 Replies

  • mcalcaterra's avatar
    mcalcaterra
    Khoros Alumni (Retired)
    3 years ago

    Hi keithkelly, you should be able to gather a user's subscriptions using API v2.0 https://developer.khoros.com/khoroscommunitydevdocs/docs/subscriptions

    Examples:

     

    SELECT * FROM subscriptions

     

    will return the current user's subscriptions, or you can also search for a specific user's subscriptions by using:

     

    SELECT * FROM subscriptions WHERE subscriber.id = '<user.id>'

     

    (replace '*' with the specific fields you want)

    Or if you prefer using API v1 there's this call https://devdocportal.khoros.com/t5/Community-API-v1-Reference/bd-p/restv1docs?section=commv1&leaf-id=User.subscriptions#User.subscriptions

     

  • I'd basically filter subscriptions by target.type = 'board' for the current user and get the the relevant board id's from that query, e.g.:

    SELECT target.id FROM subscriptions WHERE target.type = 'board'

     

    loop through the response items and assemble the board id's in a sequence.

    then use that board id sequence in the next query to get the topics from the subscribed boards:

     

    "SELECT subject, view_href, conversation FROM messages WHERE board.id IN('" + boardids?join("', '") + "') AND depth = 0 ORDER BY conversation.last_posting_activity_time DESC LIMIT 100"