Forum Discussion

damon_williams's avatar
12 years ago
Solved

Recent Posts API?

Does the Lithium API have a method that will return the top 10 most recent posts?

 

Or, the top "active" threads?

 

I am looking to surface Lithium content on another part of my website that is Confluence-based, to help drive traffic.

 

 

9 Replies

  • Inactive User's avatar
    Inactive User
    Not applicable
    12 years ago
  • JoeyMcDaniel's avatar
    JoeyMcDaniel
    Mentor
    12 years ago

    Thanks for the post!

     

    I'm having difficulty getting a return using Javascript to make that call.  Does anything stand out as incorrect here?

    <script type="text/javascript">
    $.get('https://forums.developer.ea.com/restapi/vc/posts/recent?restapi.response_format=json', null, function (d) {
    
                $('#MostRecentPosts').html("hello.");
    
            });
    </script>

     Where #MostRecentPosts is a div that I've setup on a page.

     

    FYI:  I've also updated the settings in admin to allow request from developer.ea.com.

  • samudhraa's avatar
    samudhraa
    Expert
    12 years ago

    Hi ,

     

    It looks like the standard format is something like 

     

    $.get( "ajax/test.html", function( data ) {
    $( ".result" ).html( data );
    alert( "Load was performed." );
    });
     
    You can refer the jQuery doc here.
    I changed your call to the above format , and got it working.
     
              $('.lia-component-forums-widget-board-browser').html(d.response.messages.message[0].href);
    });
     
     
    Of course , you would have to change the way I refer to message array (It's a bit crude) .But you get the idea.
     
    Hope that helps.
     
    Thanks,
    Sam
  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)
    12 years ago

    Hi JoeyMcDaniel,

     

    just MHO, if you are writing a component in Lithium studio, you may want to use rest("/post/recent") directly in your component. 

     

    if you want to display our community data in another website, you may want to create an endpoint in the community, and let your external website read the content via http get. in your endpoint, you can expose the data in any format (html/xml/json...). Opening the entire REST API to anonymous user may not be necessary.

     

  • krogala's avatar
    krogala
    Guide
    12 years ago

    there is no problem with the call itself. the problem is that Lithium does not allow cross-domain AJAX calls, at least on our forums. here is the error:

     

    XMLHttpRequest cannot load https://forums.developer.ea.com/restapi/vc/posts/recent?restapi.response_format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://docs.developer.ea.com' is therefore not allowed access.

     

    Btw, we did add our domain to the settings, but that did not help.

     

    thanks for your input.

  • krogala's avatar
    krogala
    Guide
    12 years ago

    So, now we are getting Permission Denied (303) error. Any idea what needs to be done next to make this call happen as expected?

  • krogala's avatar
    krogala
    Guide
    12 years ago

    Thanks Alok,

     

    Unfortunatelly, this does not help me much. I know what the error means, that is not the issue.

     

    I am attempting to make a REST API call from a client where the user has not been authenticated yet. Essentially what I need is a way to make this call with the auth credentials passed along with the request or be able to make the request without authentication required.

    We are using SSO and are not utilizing Lithium based authentication.

     

    If you can point me to some documentation that would help, that would be great.

     

    thanks,

    --kr