<?php require '../SageOne.php'; define('SAGE_CLIENT_ID', 'client id / api key'); define('SAGE_CLIENT_SECRET', 'client / api secret'); // If you do not already have an access token please see: // /examples/auth.php define('SAGE_ACCESS_TOKEN', 'your access token'); $client = new SageOne(SAGE_CLIENT_ID, SAGE_CLIENT_SECRET); $client->setAccessToken(SAGE_ACCESS_TOKEN); $result = $client->getServices(); echo '<pre>'; print_r($result); echo '</pre>';
<?php require '../SageOne.php'; define('SAGE_CLIENT_ID', 'client id / api key'); define('SAGE_CLIENT_SECRET', 'client / api secret'); // If you do not already have an access token please see: // /examples/auth.php define('SAGE_ACCESS_TOKEN', 'your access token'); $client = new SageOne(SAGE_CLIENT_ID, SAGE_CLIENT_SECRET); $client->setAccessToken(SAGE_ACCESS_TOKEN); $result = $client->getTaxRates(); echo '<pre>'; print_r($result); echo '</pre>';
<?php require '../SageOne.php'; define('SAGE_CLIENT_ID', 'client id / api key'); define('SAGE_CLIENT_SECRET', 'client / api secret'); // If you do not already have an access token please see: // /examples/auth.php define('SAGE_ACCESS_TOKEN', 'your access token'); $client = new SageOne(SAGE_CLIENT_ID, SAGE_CLIENT_SECRET); $client->setAccessToken(SAGE_ACCESS_TOKEN); $result = $client->createInvoicePayment(1319743, array('amount' => '40.00', 'date' => '21/02/2013', 'reference' => '000063', 'destination_id' => 2361651)); echo '<pre>'; print_r($result); echo '</pre>'; /* $result = Array ( [id] => 2783451 [date] => 21/02/2013 [reference] => 000063 [voided] => [amount] => 40.0 [source] => Array ( [id] => 2361648 [$key] => 2361648 ) [destination] => Array ( [id] => 2361651
<?php require '../SageOne.php'; define('SAGE_CLIENT_ID', 'client id / api key'); define('SAGE_CLIENT_SECRET', 'client / api secret'); // If you do not already have an access token please see: // /examples/auth.php define('SAGE_ACCESS_TOKEN', 'your access token'); $client = new SageOne(SAGE_CLIENT_ID, SAGE_CLIENT_SECRET); $client->setAccessToken(SAGE_ACCESS_TOKEN); $result = $client->createContact(array("name" => "Magnolia House", "contact_type_id" => "1", "telephone" => "01482845038", "email" => "*****@*****.**", "main_address" => array("street_one" => "42 Hull Road", "street_two" => "", "town" => "Cottingham", "county" => "East Riding of Yorkshire", "postcode" => "HU16 4PX", "country_id" => 218))); echo '<pre>'; print_r($result); echo '</pre>'; /* $result = Array ( [id] => 760900 [name] => Berkeley House [company_name] => [name_and_company_name] => Berkeley House [contact_type] => Array ( [id] => 1 [$key] => 1 ) [email] => [telephone] => [mobile] => [notes] =>
<?php require '../SageOne.php'; define('SAGE_CLIENT_ID', 'client id / api key'); define('SAGE_CLIENT_SECRET', 'client / api secret'); // If you do not already have an access token please see: // /examples/auth.php define('SAGE_ACCESS_TOKEN', 'your access token'); $client = new SageOne(SAGE_CLIENT_ID, SAGE_CLIENT_SECRET); $client->setAccessToken(SAGE_ACCESS_TOKEN); $result = $client->createInvoice(array("contact_id" => 760900, "contact_name" => "Berkeley House", "date" => "20/02/2013", "due_date" => "27/02/2013", "main_address" => "Greenwich Avenue,\nBilton Grange,\nHull,\nEast Riding of Yorkshire,\nHU9 4UY", "line_items_attributes" => array(array("service_id" => 38534, "description" => "Wellness Exercise Therapy Class on 18/02/2013 at 2pm. Instructed by Steven Gardner.", "quantity" => "1.0", "unit_price" => "40.00", "tax_code_id" => 4, "ledger_account_id" => 2517791)), "reference" => "BERKE0002")); echo '<pre>'; print_r($result); echo '</pre>'; /* $result = Array ( [id] => 1319867 [invoice_number] => SI-4 [status] => Array ( [id] => 1 [$key] => 1 ) [due_date] => 27/02/2013 [date] => 20/02/2013 [void_reason] => [outstanding_amount] => 40.0 [total_net_amount] => 40.0 [total_tax_amount] => 0.0
<?php require '../SageOne.php'; define('SAGE_CLIENT_ID', 'client id / api key'); define('SAGE_CLIENT_SECRET', 'client / api secret'); // If you do not already have an access token please see: // /examples/auth.php define('SAGE_ACCESS_TOKEN', 'your access token'); $client = new SageOne(SAGE_CLIENT_ID, SAGE_CLIENT_SECRET); $client->setAccessToken(SAGE_ACCESS_TOKEN); $result = $client->getLedgerAccounts(); echo '<pre>'; print_r($result); echo '</pre>';
<?php require '../SageOne.php'; define('SAGE_CLIENT_ID', 'client id / api key'); define('SAGE_CLIENT_SECRET', 'client / api secret'); $client = new SageOne(SAGE_CLIENT_ID, SAGE_CLIENT_SECRET); $callbackURL = 'http://example.com/auth/sageone/callback'; // We need to build the authorise url and redirect user to authorise our app if (!$_GET['code']) { $authoriseURL = $client->getAuthoriseURL($callbackURL); // redirect user header("Location: " . $authoriseURL); exit; // We now have the authorisation code to retrieve the access token } else { $accessToken = $client->getAccessToken($_GET['code'], $callbackURL); echo '<pre>'; print_r($accessToken); echo '</pre>'; // or echo '<br>'; echo $accessToken['accessToken']; // Note: The access token does not expire so you can now store that access // token in your database against that user or as a constant if you are // talking with the api for your account only. }