1. Go to this page and download the library: Download pronamic/twinfield library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pronamic / twinfield example snippets
$config = new \Pronamic\Twinfield\Secure\Config();
$config->setCredentials('Username', 'Password', 'Organization', 'Office');
$config = new \Pronamic\Twinfield\Secure\Config();
$config->setOAuthParameters('clientID', 'clientSecret', 'returnURL', 'Organization', 'Office', true);
//the true parameter at the end tells the system to automatically redirect to twinfield to login
$customerAddress = new \Pronamic\Twinfield\Customer\CustomerAddress();
$customerAddress
->setDefault(false)
->setType('invoice')
->setField1('Testing field 1')
->setField2('Testing field 2')
->setField3('Testing field 3')
->setPostcode('1212 AB')
->setCity('TestCity')
->setCountry('NL')
->setTelephone('010-12345')
->setFax('010-1234')
->setEmail('[email protected]');
$customer->addAddress($customerAddress);
use \Pronamic\Twinfield\Customer as TwinfieldCustomer;
// Config object prepared and passed to the CustomerFactory
$customerFactory = new TwinfieldCustomer\CustomerFactory($config);
//$customer = new TwinfieldCustomer\Customer();
// Attempt to send the Customer document
if($customerFactory->send($customer)){
// Use the Mapper to turn the response back into a TwinfieldCustomer\Customer
$successfulCustomer = TwinfieldCustomer\Mapper\CustomerMapper::map($customerFactory->getResponse());
}
use \Pronamic\Twinfield\Customer as TwinfieldCustomer;
// Config object prepared and passed into the CustomerFactory
$customerFactory = new TwinfieldCustomer\CustomerFactory($config);
$customers = $customerFactory->listAll();