Using the Xero API with CFML

Private Application – Matthew Bryant

Xero API Private Application code sample – contributed by Matthew Bryant.

Xero.cfc –  on ›

This is an outline guide on how to use the Xero API with a private API application. If you have any tips or suggestions, please contribute them here and we will update our documentation.

Self-signed certificate generation

Using OpenSSL

Mac users go to the Terminal Application

Windows users download openSSL for windows

  1. openssl genrsa -out xero_privatekey.pem 1024
  2.  openssl req -newkey rsa:1024 -x509 -key xero_privatekey.pem -out xero_publickey.cer -days 365
    (The .cer will be needed when creating the API application in the Xero Developer Centre ‘Add Application’ screen)
  3.  openssl pkcs8 -topk8 -nocrypt -in xero_privatekey.pem -out xero_privatekey.pcks8
    (Extracts the private key in PKCS8 format used for signature in this cfc)

Create Xero Application from Developer Center

Use public key (.cer) generated above to create a Private Xero Application

Sample Code:

<cfsavecontent variable="xeroXML">
        <Name>ABC Limited</Name>
        <Name>DEF Limited</Name>

<cfset oXero = createObject("component", "").init( 

<cfset stResult = oXero.sendRequest( method="POST",
  SummarizeErrors="false") >

<cfdump var="#stResult#" />

Keen to contribute a partner app example? Drop us a line and we’ll recognise your contribution here.