PHP SDK
SDK for PHP
The SDK is a PHP based library that makes it easy to use the Axis LMS API in your PHP code.
You can download the SDK files here:
https://files.atrixware.com/files/axis/resources/axisapi.sdk.php.zip
Basic Usage
Here is a basic example of calling the Axis API using the PHP SDK. This example sets the return type as XML but you can also set it to return as JSON. Note that your code will also have to include the server and API key not shown in this example. Check out the sample files and template file in the PHP SDK for more details:
result = axisapi\call([
endpoint => "user/getlist",
p1 => "admin",
returntype => "xml"
]);
While the Axis API natively returns results as XML, using the SDK you can set the result to be returned as either XML or JSON. You can use the built-in PHP functions to parse through either kind of result. When converted to JSON, the data could be in a few different formats (flat object, or an object of arrays for example, depending on the complexity of the data).
When handling tagged data which some endpoints return back as values to some nodes, the PHP SDK has a few functions to help you parse through the results of that kind of data structure:
axisapi\hasTaggedData($string)
This function will return true if the $string
passed has tagged data.
asixapi\getTagNames($string)
This function will return an array of tag names in $string
.
axisapi\getTagData($tagname, $string)
This function will return the data value for $tagname
in the $string
containing tagged data.
The PHP SDK consists of several files including a starting template file you can use to start your coding, and some example files to get you started.
To set it up, follow these steps:
-
Create a folder on your web server to put the PHP files.
-
Unzip the SDK files, and copy to the folder on your web server.
-
To try the sample files, open them up and populate the required fields with data for your LMS.
Note: If you are using the legacy SDK/API wrapper (which used the APICommand() function), you can still use the same coding style with the new SDK, although you won't be able to take advantage of the benefits the new SDK offers.