Forum Discussion

mayank's avatar
11 years ago

Lithium API to create a module to get the 3 most recent posts on other server

Lithium API to create a module to get the 3 most recent posts on other site

  • You will need to traverse the response object to find out the data you want

     

    Examples:

     

        success: function(data) {
    		var resp = data.response;
    		
    		alert("Response status is: " + resp.status);
    		alert("Response messages: " + resp.node_message_context.message.length);
    		alert("First message subject : " +resp.node_message_context.message[0].subject.$);
    		 
        }

     Of course the above are merely examples and should not be used in production - but it gives you an idea.

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)

    Hi Mayan,

     

    welcome to the Lithosphere! I am not sure which use case you have in mind. What do you mean by "on other server"? Can you clarify a bit more what you are trying to achieve?

     

    • Do you mean display recent posts from the Lithum community on another site?
    • Or, do you mean using custom components to retrieve informations from a URL outside the community?

    In the first case, the Lithium Activecast widgets can help you out. There is a specific one to retrieve the latest topics.

    In the second case, you may want to investigate using the Studio Endpoints (which allow you to make http calls to external sites)

     

    Cheers,

  • Thanks a lot for sharing your valuable time.I want to :

     

    •  display recent posts from the Lithum community on another site?

     

    Can you please share its steps

    • PaoloT's avatar
      PaoloT
      Lithium Alumni (Retired)

      Hi Mayank,

       

      thanks for the additional details. The easiest way could be to implement the "Latest Topics" activecast widget. If you download the PDF attached in this article you will find all the steps for the implementation at pages 4 and 5.

       

      Let us know if that helps,

       

      • mayank's avatar
        mayank
        Ace

        Can you please give me a way so that i can done it with Rest api...

  • Can anybody help me in fetching latest post with rest api...

     

    Here is my code :

     

    $.ajax({
    type: "GET",
    async: false,
    // dataType: "text/HTML",
    crossDomain:true,
    url: 'http://community.edifecs.com/restapi/vc/posts',
    success: function(response) {
    alert('success');
    }
    });

     

    Output :(Firebug Console)

    XML Parsing Error: no element found Location: moz-nullprincipal:{3237c74c-1574-44cd-9806-2b8d3fe09433} Line Number 1, Column 1: