Commits

Greg Salt committed 1432a3e

Cerberus Library

Comments (0)

Files changed (2)

docs/developers.rst

 
 We have made a library available that makes it easy for you to integrate Cerberus into your own addons. It is released under the MIT licence so you can use it for commercial purposes if required.
 
+Cerberus Library
+----------------
 
+The library can be used just like any other EE or CodeIgniter library. Here is an example of loading the library and passing in an array of configuration parameters an EE addon:
+
+.. code-block:: php
+
+   <?php
+
+   $params = array(
+       'hostname' => parse_url($this->EE->config->item('site_url'), PHP_URL_HOST),
+       'update_access_key' => 'your_access_key'
+   );
+
+   $this->EE->load->library('cerberus', $params);
+
+The hostname and access key are the only required parameters. See the `API`_ for full details of how to use the library.
+
+You should then pass your data as a JSON-encoded array of arrays to the library ``encrypt`` method:
+
+.. code-block:: php
+
+   <?php
+
+   $data = array(
+       array(
+           'username' => 'username',
+           'screen_name' => 'screen_name',
+           'email' => 'email',
+           'ip_address' => 'ip_address',
+           'url' => 'url'
+       )
+   );
+
+   $encrypted = $this->EE->cerberus->encrypt(json_encode($data));
+
+.. attention::
+
+   Note that you must send keys for all five member fields even if they are empty strings
+
+Having encrypted your data you can now send it the Cerberus database:
+
+.. code-block:: php 
+
+   <?php
+
+   $response = $this->EE->cerberus->update($encrypted);
+
+If all goes will the ``$response`` will contain a JSON-encoded string indicated success:
+
+.. code-block:: json
+
+   {"code": 200, "message": "Ok"}
+
+Please see `Response Codes`_ for all the possible API responses.
+
+.. _`API`: api.html
+.. _`Response Codes`: response-codes.html
+
    getting-started.rst
    registration.rst
    updater.rst
+   developers.rst
 
 
 
-    Indices and tables
-    ==================
-
-    * :ref:`genindex`
-    * :ref:`modindex`
-    * :ref:`search`
-