The PHP Apstrata SDK wraps the Apstrata REST APIs making it very easy to interact with Apstrata from within PHP code.
The SDK exports the following classes: APSDBClient and KeyValue.
Method | Description | Parameters | Returned Value |
---|---|---|---|
APSDBClient | Constructor. Creates a php client object that can be used to make owner, user, or anonymous requests to Apstrata. |
| An APSDBClient object. |
callApi | Makes requests to Apstrata to execute the specified API. |
| An array containing the response keyed by:
|
Method | Description | Parameters | Returned Value |
---|---|---|---|
KeyValue | Constructor. A key-value pair. |
| An instance of KeyValue. |
Click here to download the PHP Apstrata SDK source code.
Click here to download a sample application that demonstrates user registration, authentication, and facebook feed posting.
Examples:
An owner saving a document to Apstrata:
require_once 'APSDB/APSDBClient.php'; require_once 'APSDB/Common/KeyValue.php'; $service = new APSDBClient("MyAccountKey", "MyAccountSecret"); $params = array(); array_push($params, new KeyValue("apsdb.store", "DefaultStore")); array_push($params, new KeyValue("apsdb.documentKey", "MyDocKey")); array_push($params, new KeyValue("FirstName", "Mike")); array_push($params, new KeyValue("LastName", "Tyson")); array_push($params, new KeyValue("apsdb_attachments", "/home/me/records.txt", true)); array_push($params, new KeyValue("FirstName.apsdb.fieldType", "string")); array_push($params, new KeyValue("LastName.apsdb.fieldType", "string")); $response = $service->callApi("SaveDocument", $params); echo "<pre>"; print_r ($response); echo "</pre>"
A user issuing a query to get the document:
require_once 'APSDB/APSDBClient.php'; require_once 'APSDB/Common/KeyValue.php'; $service = new APSDBClient("MyAccountKey", "MyUserPassword", "MyUserLogin"); $params = array(); array_push($params, new KeyValue("apsdb.store", "DefaultStore")); array_push($params, new KeyValue("apsdb.query", "apsdb.documentKey=\"MyDocKey\"")); array_push($params, new KeyValue("apsdb.queryFields", "apsdb.documentKey")); array_push($params, new KeyValue("apsdb.resultsPerPage", "10")); array_push($params, new KeyValue("apsdb.pageNumber", "1")); array_push($params, new KeyValue("apsdb.count", "true")); $response = $service->callApi("Query", $params); echo "<pre>"; print_r ($response); echo "</pre>";
An owner downloading a file saved in a document:
require_once 'APSDB/APSDBClient.php'; require_once 'APSDB/Common/KeyValue.php'; $service = new APSDBClient("MyAccountKey", "MyAccountSecret"); $params = array(); array_push($params, new KeyValue("apsdb.store", "DefaultStore")); array_push($params, new KeyValue("apsdb.documentKey", "MyDocKey")); array_push($params, new KeyValue("apsdb.fieldName", "apsdb_attachments")); array_push($params, new KeyValue("apsdb.fileName", "records.txt")); array_push($params, new KeyValue("apsdb.setContentDisposition", "true")); $response = $service->callApi("GetFile", $params, "/home/me/tyson_records.txt"); echo "<pre>"; print_r ($response); echo "</pre>";