Forum Discussion

qingliu's avatar
qingliu
Contributor
12 years ago
Solved

Using REST API to build a customized featured topic widget

Hi All,

 

I would like to build a customized featured topic widget which will just pull the ehtire categories but not pull the featured blog posts. 

 

I am reading the article in here: http://lithosphere.lithium.com/t5/support-knowledge-base/Using-the-Featured-Topics-feature/ta-p/50772

 

However, the rest CALL return nothing http://forum.kpn.com/restapi/vc/threads/style/board/featured when i tried to use that. 

 

If i give the category ID, it will return the threads which has been featured. 

 

http://forum.kpn.com/restapi/vc/categories/id/KPN_Internet_Bellen_ITV/threads/featured/?page_size=3

 

can you please point out what I have done wrong? 

 

Thank you. 

 

 

Cheers,

Qing

  • Hi Qing,

     

    There are a couple of reasons you're not getting any results. First, the interaction style key you want to use is "forum" instead of "board". Second, the call you're using will only return results from boards directly under the community level, rather than boards in categories. See this note in the documentation for that method:

    "At category or wider scopes, only threads in directly nested boards are included, not those in boards in nested categories."

     

    To get the featured threads for nested categories too, you should use the following method:

    threads/style/[style] /featured/nested

     

    For example: 

    http://forum.kpn.com/restapi/vc/threads/style/forum/featured/nested

     

     

    I hope this helps!

6 Replies

  • I don't think there's a way to get featured threads at a community level (although I could be wrong).

     

    You could retrieve the featured threads from each category and concatenate them (this can be done in FreeMarker or JavaScript).

  • qingliu's avatar
    qingliu
    Contributor
    12 years ago

    Hi Nathan,

     

    Thank you.  That means that I will need to have build this widget in two steps. 

     

    1 Step 1:  Using /estapi/vc/categories to get all categories id  . (like i have 6 categories ) 

     

    2. Step2:  Loop through all categories to get featured topic. 

     

    I think that is too much REST calls to achieve that. 

     

    In AllenS post said that: 

     

    In order to do that, I would recommend that you use the following REST calls:

     

    /restapi/vc/threads/style/board/featured

    /restapi/vc/threads/style/blog/featured

     

    These will return the featured threads for boards and blogs respectively. 

     

    But I am not able to get any return by trying these two REST API call

     

    Cheers,
    Qing 

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Hi Qing,

     

    There are a couple of reasons you're not getting any results. First, the interaction style key you want to use is "forum" instead of "board". Second, the call you're using will only return results from boards directly under the community level, rather than boards in categories. See this note in the documentation for that method:

    "At category or wider scopes, only threads in directly nested boards are included, not those in boards in nested categories."

     

    To get the featured threads for nested categories too, you should use the following method:

    threads/style/[style] /featured/nested

     

    For example: 

    http://forum.kpn.com/restapi/vc/threads/style/forum/featured/nested

     

     

    I hope this helps!

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Unfortunately not, a second REST API call will be required to get the board title.

     

    If you're going to be making these call externally (rather than in a custom component in the community) and are worried about the number of calls you have to make, you might want to check out this TKB article on condensing REST API calls into an endpoint:

    http://lithosphere.lithium.com/t5/developers-knowledge-base/Using-Endpoints-to-Condense-REST-API-Requests/ta-p/88908

  • sdujari's avatar
    sdujari
    Mentor
    11 years ago

    Hi AdamN I'm trying to use this to pull featured articles from a TKB. I'm doing the following but it doesn't work:

     

    http://...com/restapi/vc/boards/id/AgileManagerCustomerStories/topics/style/tkb/featured

     

    http://...com/restapi/vc/boards/id/AgileManagerCustomerStories/topics/style/tkb/recent

    does work though but doesn't tell me which topics are featured. Any thoughts?

     

    Is there any way to use /recent to see which topics are featured?