xTuple ERP PHP REST API Client Example using the Google APIs Client Library for HP that uses Google APIs Client Library for PHP and JSON-Patch PHP library to interface with xTuple's REST API.
These are some very basic DELETE, GET, PATCH and POST request examples.
WARNING: These examples are in no way secure or using best practices for PHP application. This is meant for educational purposes only.
There is a lot more that could be done to expand on these examples. TODO: Create a basic user interface. TODO: Change POST into an add form that creates fields from the JSON-Schema. TODO: Change PATCH into an edit form that creates fields from the JSON-Schema.
- Clone or download this repo:
git clone git@github.com:xtuple/xtuple-php-rest-client-example.git
2.Copy this directory xtuple-php-rest-client-example to a path exposed by your PHP server.
For example:
/var/www
- Register for an OAuth 2.0
Services AccountClient in your xTuple Mobile Client'sOAUTH2interface. You will be prompted to download a PK12 keystore file. See OAuth 2.0 Service Accounts Scenario for more information. - Save the PK12 keystore file in the same directory as this file and the
index.phpfile. - Copy the
sample_local_config.phpfile tolocal_config.phpand edit it to set all of your environment and OAuth 2.0 client specific settings:
cp sample_local_config.php local_config.php
- Visit the
index.phpfile on your PHP server. For example:
https://localhost/php-client-example/index.php
Note, make sure your xTuple Mobile Client is running before loading index.php.
You should be presented with a list of contacts. Initially, at the bottom of
the list, there is a link to Add Contact 42. You can click on a contact's
number to view it. Each contact has links to Delete it or Add a comment.
Copyright (c) 2012-2014 xTuple http://www.xtuple.com/