PHPAudit Licensing Method: Accessing the Local Key API

This article will show you how to use the SPBAS equivalent of the PHPAudit v2 local key API request. The resulting key is fully backwards compatible with PHPAudit v2. Also note, we no longer use the XMLRPC package.

You will need a text editor, SSH or FTP, SPBAS installed & configured and you must have a basic understanding of PHP, SPBAS and the logic behind RESTful API's. Let's begin!


Step 1: Obtain an API Key


The API key is used to authenticate the API request. It will always be 32 characters and should be kept private as a published key would allow anyone access to your API ( and as a result of that, your SPBAS data). Follow these steps to find your API key:


1. Login to SPBAS

2. Click Settings and then Setup

3. Click the m3 tab

4. Look for API Key: and make note of it, you'll need it.



Step 2: Accessing the API


Use the code snippet below as a standalone file for testing. Later, after you've confirmed it's working, you can embed it into your script or use it where ever it's needed.

Your license must be based on a with local key licensing type.


<?PHP
/**
* This file is included in the dev kit attached to this article.
*
* Please note! Never include api.php in your production code.
* Always embed it instead. Embed it into the file you want to
* protect or into one of your other very important files.
*
* If you include it, the end user can simply rewrite it.
*/
include_once 'api.php';

// the path to the SPBAS api/ directory
$api_handler='http://domain.com/api/index.php';

// your API Key from step 1
$api_key='';

// the module
$mod='license';

// the task name
$task='get_local_key';

/*
For this particular API you must enter the license key string

This string might look like: ABCSoft-23f342335

In which case you would enter:
$data=array('license_key' => 'ABCSoft-23f342335');
*/
$data=array('license_key' => '');

// query the API! Notice the last argument, it means skip XML as 
// this API doesn't use XML. You simply get the key in whole.
$request=api::query($api_handler, $api_key, $mod, $task, $data, true);

// view_local_key() shows you the local key, it's hidden otherwise
// because the local key includes the PHP opening and closing tags.
// It's just a debug function :)
api::view_local_key($request);
?>

Andy Rockwell

Print Article

Add Bookmark

Local_Key_API_Dev_Kit.zip


Was this article helpful?

Yes, it was helpful.

No, it was not helpful.



Related Articles

Powered by SPBAS Business Automation Software