Examples
Small, self-contained examples. Each folder shows one thing, with an example.php you can run and a README.md that explains it.
-
Register
http://localhost:8765/callbackas redirect URI for your client in the Twinfield developer portal. -
Run any example, for instance:
Terminal window php examples/offices/list-offices/example.php
The first time, the example asks for your client ID, client secret and redirect URI, opens the Twinfield login in your browser and asks for a default company. Everything is saved in ~/.config/twinfield/, so after that examples start right away. Run composer twinfield:setup to change these values.
Every example starts the same way:
require __DIR__ . '/../../../vendor/autoload.php';
$twinfield = Example::twinfield();In your own application you create the client yourself: see Authentication.
Add TWINFIELD_DEBUG=1 to any example to see the SOAP requests and responses.
Getting started
Section titled “Getting started”- Login: let a user log in and get the refresh token.
- Authentication: create a client in your own application.
- Token info: organisation, user and cluster of an access token.
- Error handling: catch errors and act on their code.
Offices
Section titled “Offices”- List offices: all offices the user has access to.
- Switch company: the same call for several companies.
Finder
Section titled “Finder”- Search dimensions: search with pattern, options and limit.
- Paginate: go through all results page by page.
Periods
Section titled “Periods”- List periods: years of the company and the periods of a year.
- Rename period: change a period with a command (changes data).
ProcessXml
Section titled “ProcessXml”- List companies: all companies, with a request without company.
- Read dimension: read a customer and handle errors.