Integrate API into new module

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
LorettaSmith
New Member
New Member
Posts: 1
Joined: Sat Nov 02, 2024 4:53 am

Integrate API into new module

Post by LorettaSmith »

Hi everyone,

I am working on a new module and would like to integrate an API function to fetch data from an external service. I was wondering if there is a best way to do this without affecting the performance of the existing module? Has anyone done something similar and can share their experience or sample code? ??? ???

Thanks a lot!
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1961
Joined: Mon Jan 29, 2007 4:47 pm

Re: Integrate API into new module

Post by Jo Morg »

I do that a lot, but it is not a small task, depending quite a bit on the size and number of features the API offers, and the ones you want to deploy with the API.
Also the methodology may vary depending on which technology you use to access the endpoints and any webhooks that may provide. The access of documentation and code samples (or even complete libs) is paramount to how you choose to organize your code.
Typically I create a number of classes under my module's lib folder, which CMSMS can auto load without having to worry with that and, if there is already a lib for PHP I put it on another folder under lib and explicitly include it. Whether I create or not a wrapper class of my own is a matter of assessing the characteristics of the lib, if I use just a sub-set of features or all of them, etc.
There is no "one size fits all" solution but this is my usual approach.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Post Reply

Return to “Developers Discussion”