Jump to content

Tip: Custom API Function and Local API Usage


Recommended Posts

Hey Guys and Gals;

 

Ever wanted to build your own custom API modules?

 

Through my days of creating OAuth I figured out the age old questions, how do I create my own API command and how do I include the WHMCS API locally without making a request to the WHMCS API.

 

I have fully commented the code below for your benefit and understanding on this.

 

<?php

/*
Custom API Function
Name the file all lowercase and with the command to call
Save File To: /includes/api/

The following are defined by the OAuth Server:
	ROOTDIR is a constant that holds the absolute path of WHMCS install
	The file dbconnect.php is included. This establishes a mysql connection.
	The file includes/functions.php is included. This hold various WHMCS commands.
*/

// $silent is defined as true if its valid API request. Else denies them access....
// Do not define silent! It is defined by the OAuth server!

if ($silent == true) {



}

 

Though this was created for OAuth server I created. The same principles do apply to the actual WHMCS API.

 

Including dbconnect.php and includes/functions.php into your code and defining "$silent = true" will allow you to use the API anywhere throughout your site.

 

Hope this helps and happy developing! 8)

Link to comment
Share on other sites

I was to the understanding that the $silent variable was only used to not send out email while calling the sendmessage function.

 

It would seem that WHMCS uses silent throughout their platform then. Thanks for that tip Sparky. I actually wasn't aware of that :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated