Jump to content
  • 0
tasgray

Extending API?

Question

Hi everyone,

Since 7.4 release it no longer seems possible to extend the API using methods described in other posts. Does WHMCS plan to make this available again? We desperately need functionality to export information that is not available through builtin API methods. 

Many thanks

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
On 5/22/2018 at 8:24 PM, laracraft4321 said:

You can extend the API to include custom resources. Most resources are correlated to Omeka records, but you may include non-record resources as well. In your plugin class, register your resource using the api resources filter,

Thanks for your response. Can you point me to some documentation? I wasn't able to find anything myself.

Share this post


Link to post
Share on other sites
  • 0

Hello Tasgray,

There has never been an officially supported method for extending the WHMCS API. After 7.4 came out I came across a thread in our forums where a third party dev suggested a method and appended a comment to try and advise against what they recommend. Ultimately an API is a promise between a software product and the consuming developers to communicate in a specific way. We take API compatibility and longevity really seriously. Those promises really are not present when someone places 3rd party files in a directory.

More broadly best I can tell when customizing WHMCS as a developer you are looking to do some combination of three things:

1) I want to trigger some action in WHMCS from an external system.
2) I want to get some information from WHMCS for a 3rd party system.
3) I want to provide some helper functions or libraries for WHMCS customization.

For the first need, addon modules with client area functions should be able to do everything you are currently doing in your code. The validatelogin api call will give you the information to authenticate and the addon module will have permission to do any task you need.

For the second there are a few options, one is our existing APIs, if you have a convenience function to return data our API's provide you could filter our API client side. Another is to use the reply of an addon module in the clientarea. Another option is to use a custom created page: https://developers.whmcs.com/advanced/creating-pages/ - this is most useful if you need lots of structured data (json for example).

For the third using namespaced functions and including them in the vendor/ directory is our recommended solution. These is the least well developed of the three right now, its something we are discussing internally but not something we have a well supported story to present at this time. I would be really careful going this direction and if you need to go there, I'd love to hear more details about what you are doing, what your issues and goals are, what your development practices and software lifecycle look around that, so that it can help inform our internal conversations.

Hope that helps,

Nate C

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Hi @WHMCS Nate,

Thank you for the most concise response to any API query I have seen so far.

I do agree that it's a dangerous path to try and 'hack' together an API or custom call and expect it to work perpetually with so many changes that happens to software.

As much as I agree with this, and I understand completely that there are not a Microsoft size team of developers working on the software, if I'm happy to take the risk of something breaking due to an upgrade that breaks the code I've written, then it should be up to the dev to take the risk, same as with any other piece of software.

Due to missing API functionality something as simple as Getting customer uploaded files from WHMCS is not accessible, I've had to write an SQL query to pull that data out of the system and because I can't write an API call it needs to be in a separate container and separate function to get this cleanly into the site.

Same with updating a user login? I can display the last login to the user, but I can't then update it to show when they've logged in via my own website? So I had to SQL that also? These should be simple, when the dev's write the get API they should write the set API too?

The biggest 'omitted' feature in the API from my view is the ability to pull PDF files out of the system and into an external system? It's impossible to let the customer get their invoice, I understand that it's created on the fly, but there should be some sort of a way to get it going. There's been a working example online from one user, however I haven't been able to get that working on 7.5

http://thewanderingsysadmin.net/?p=35#comment-8709

 

I'm very very happy to take the time to learn how to create an add-on module and then extend it with a return call however there is less than zero documentation on how to even think about beginning a process like this? Which makes it hard for someone like me who wants to improve as a developer + wants to try stay within the rules; if you can put me in the right direction to get something like that sorted that'd be great and I'm sure it'd be a platform for others to use also.

 

If you do have any assistance material or documentation on how we can get things started that'd be much appreciated.

 

Thanks ! 

Share this post


Link to post
Share on other sites
  • 0

Hello @wellconnit,

Sorry my reply didn't include a link to the addon module documentation about creating client area output or addon modules in general. You can see our docs on creating addon modules here:

https://developers.whmcs.com/addon-modules/getting-started/

The documentation for the client area output I'm recommending is:
https://developers.whmcs.com/addon-modules/client-area-output/

We've also published a sample addon module with extensive comments and some best practices we've learned here:

https://github.com/WHMCS/sample-addon-module

I'd advise you to check out how we use a client area dispatcher for client area output. If you have a more complex client area layout it may be really important for you.

Hope that helps get you started, the sample addon module has more then 800 lines of code and comments - I'd call that a bit better then less then zero ;)

Nate

 

Share this post


Link to post
Share on other sites
  • 0

Hi @WHMCS Nate,

 

I definitely look forward to going over that documentation to try and help with getting things working that aren't available out of the box.

Quote

"Ultimately an API is a promise between a software product and the consuming developers to communicate in a specific way. We take API compatibility and longevity really seriously. "

Just on that point, I found a bug in the API, #CORE-11360, it was related to GetTLDPricing and someone broke the functionality. It was only when I brought it to support's attention that it ended up getting fixed in a subsequent release. Again, I understand that not all scenario's can be accounted for due to obvious reasons, but if WHMCS can release software that has issues and then wait until the next version to patch them, I believe that it should be the prerogative of the developer to include these things in their own website.

 

Just my 2 cents.

 

Thanks for the content though ! 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines