Forum Discussion

RyanFarley's avatar
RyanFarley
Contributor
15 years ago

Getting a list of recent messages via API

I am having some difficulty in getting a list of recent messages via the API.

 

I located a post in these forums that showed me the following URL:

http://lithosphere.lithium.com/lithium/restapi/vc/posts/recent

 

That URL works on the lithosphere forums, but not here:

http://community.sagesaleslogix.com/slsl/restapi/vc/threads/recent

 

I am not sure why it isn't working on my community site.

 

1) Does anyone know why this works on this site but not on mine?

2) Does anyone know other ways to get the list of recent messages?

 

 

Strangely enough, the URL to get the list of recent threads does work on my community: http://community.sagesaleslogix.com/slsl/restapi/vc/threads/recent

 

Thanks!

10 Replies

  • JakeR's avatar
    JakeR
    Khoros Oracle
    15 years ago

    You may have accidentally duped the threads that both work in your post.  When I click on the links, I have success on both.  Was one of them supposed to not work?

  • RyanFarley's avatar
    RyanFarley
    Contributor
    15 years ago

    Yeah, sorry. I did post the wrong link. I posted the link that works in *this* community, which is:

    http://lithosphere.lithium.com/lithium/restapi/vc/posts/recent    <-this works here, but not on mine

     

    If I use that same URL on my community it does not work (although the URL for recent threads does work). It does not appear to be a permissions issue from the response. The response gives a 501 error stating "Unknown path element at node 'community'."

     

    This one does not work for me:

    http://community.sagesaleslogix.com/slsl/restapi/vc/posts/recent

     

    I am stuck :( Thanks for any help.

  • JakeR's avatar
    JakeR
    Khoros Oracle
    15 years ago

    Yeah, that is a bit odd.  I am an anonymous user and I can see this API response just fine:

     

    http://community.sagesaleslogix.com/slsl/restapi/vc/boards/id/hello

     

    So the good news is that we at least have a "dial tone".

     

    Now, when I try to get the latest messages from that board in particular, I am successful:

     

    http://community.sagesaleslogix.com/slsl/restapi/vc/boards/id/hello/messages/latest

     

    And when I go into the Community level and want to find out what the names of the categories are, I am successful:

     

    http://community.sagesaleslogix.com/slsl/restapi/vc/categories

     

    But you're right, when I try to get recent posts from the Category or Community level, I'm having trouble...

     

    I'll keep looking into this.  BTW, when is your upgrade to v9?

     

  • RyanFarley's avatar
    RyanFarley
    Contributor
    15 years ago

    Thanks for all the help Jake.

     

    The upgrade to v9 is out of my hands and unfortunately, I don't see it happening any time soon :(

     

    Basically what I need is to be able to retrieve any new posts "today" (or at least since a certain date/time). Do you have any ideas for how to get all posts since a certain date/time?

     

    Thanks again.

  • JakeR's avatar
    JakeR
    Khoros Oracle
    15 years ago

    Yeah, I see.  In a perfect world the user would have a button that gets all the posts that have occurred since they lost logged in...oh wait, that is coming in our latest v9 release. Heheh.

     

    Seriously though, for the here and now, I've been thinking about your challenge.

     

    When you run that call, it looks like it returns all the threads that have been updated in the last week, one thing I might suggest is running it with a little query string parameter tacked on:

     

    http://community.sagesaleslogix.com/slsl/restapi/vc/threads/recent?page=1&page_size=10

     

    With those parameters tacked on it looks like it returns the threads just in the last day or two (of course you can fiddle with the numbers in those parameters in order to expand or reduce the results).

     

    Would something like that work for you? 

     

    There are other parameters that you can use (contained within the REST API docs that you can get from your CSM).  Maybe these ones are the ones that you should be using instead of the ones that I tacked on:

     

    • topic_sort_order - Specifies the order in which threads are listed in a message list. Possible values:
      • last_post_date - Threads are sorted by the dates the threads were started in descending order, with the newest topics appearing first
      • topic_start_date - Threads are sorted by the date of the newest message in each thread in descending order, with the threads with newest messages appearing first.
  • aitchon's avatar
    aitchon
    Contributor
    14 years ago

    How far back in time will the recent method return posts?  I see that using the page and page_size parameter will allow me to page through recent posts.  Is there a limit on how far back I can page through?

  • RickyS's avatar
    RickyS
    Lithium Alumni (Retired)
    14 years ago

    Hi aitchon,

     

    Hypothetically, you should be able to go back as far as you want with the recent call if you set your page number and page_size parameters large enough to pull posts all the way back to the beginning of your community.  With that said comes a caveat that if your rest calls are too ambitious, it may put strain on your production server.

     

    Regards,

    Ricky

  • pooraju's avatar
    pooraju
    Contributor
    14 years ago

    Hi, 

     

    Is there any way to get latest message of a specified author ? I am able to get latest message using messages/latest but I need messages per author.

    I also tried with search/messages but in vein.

     

    Thanks in advance