Forum Discussion

Kev_B's avatar
Kev_B
Advisor
6 years ago

Pulling community data to an external site

Hi,

Hoping this is a simple enough request, but a search didn't yield any results to help explain what needs to be done.

Our organisation would like to pull some community threads into a module on a non-community web page. I'm familiar with the API calls to build what they need, but I've not done so for the data to be external to community and therefore making those calls on the community API.

Does anybody have any experience of doing this? If so, could you provide any practical tips for what would need to be done? Do I still use FreeMarker, or would it need to be done like an AJAX request since it's on a different server to community?

Thanks in advance,

Kev

  • Kev_B 

    > Building outside of the platform do I still use FreeMarker, or do I need to make calls back to the API (like an AJAX call etc) and handle the response before using the data?

    You can do both, e.g. talk directly to the API via JavaScript/AJAX, but then you have to deal with OAuth/session keys to authenticate against the API, which is slightly annoying 😃... But depending on the data you want to fetch it might be necessary...on the other hand if it is simply a list of topics that are visible to anybody anyways, you can save yourself the hassle. That means you just build your custom component with FreeMarker as you are used to, make it output HTML, then add the component to a custom endpoint and then fetch that endpoint via AJAX from the external site, that's the easiest way. You can also just aggregate the data you need and output JSON from the endpoint, then fetch that JSON data via AJAX and render it via JavaScript directly on the external site....

    > Is there a specific URL to use or can I still use an LiQL query when calling from an external platform?

    Yeah, something like https😕/api.lithium.com/community/2.0/<communityid>/search?q=SELECT+*+FROM+messages+WHERE+replies.count(*)%3D0&api.pretty_print=true

    see: https😕/community.khoros.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2&v2.main=gettingstarted

    > How do I pass the API key when making the call?

    Depending on the API version you want to use you have to either negotiate a session key (v1) or an OAuth token (v2) with the API.