Child pages
  • PHP SDK
Skip to end of metadata
Go to start of metadata

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.

MethodDescriptionParametersReturned Value
APSDBClientConstructor. Creates a php client object that can be used to make owner, user, or anonymous requests to Apstrata.
  • accountKey (mandatory):
    • The Apstrata authKey of your account.
  • accountSecret (optional):
    • Mandatory for owner requests: the Apstrata secret of your account.
    • Mandatory for user requests: the user password.
    • For anonymous requests: null.
  • userLogin (optional):
    • Mandatory for user requests: the user login.
    • For anonymous and owner requests: null.
An APSDBClient object.
callApiMakes requests to Apstrata to execute the specified API.
  • action (mandatory): The name of the Apstrata API that will be executed.
  • arrParams (mandatory): The array of $KeyValue object containing all the parameters to be passed to the API call.
  • destinationPath (optional): File in which to save the response body. Note that the headers will never be written to the file, but will be returned in the response as usual. This parameter is required if the GetFile API is executed.
An array containing the response keyed by:
  • response - the body of the Apstrata response.           
  • headers - the headers set by Apstrata.
MethodDescriptionParametersReturned Value
KeyValueConstructor. A key-value pair.
  • key (mandatory).
  • value (mandatory).
  • isFile (optional) - should be set to true if the key-value pair represents a file object being uploaded.
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>";



 

 

  • No labels