/home/desid573/public_html/gcdriver/payment/xero/tests
Edit: /home/desid573/public_html/gcdriver/payment/xero/tests/tests.php (33327B)
refreshToken($oauthSession['oauth_token'], $oauthSession['oauth_session_handle']);
if ($XeroOAuth->response['code'] == 200) {
$session = persistSession($response);
$oauthSession = retrieveSession();
} else {
outputError($XeroOAuth);
if ($XeroOAuth->response['helper'] == "TokenExpired") $XeroOAuth->refreshToken($oauthSession['oauth_token'], $oauthSession['session_handle']);
}
} elseif ( isset($oauthSession['oauth_token']) && isset($_REQUEST) ) {
$XeroOAuth->config['access_token'] = $oauthSession['oauth_token'];
$XeroOAuth->config['access_token_secret'] = $oauthSession['oauth_token_secret'];
$XeroOAuth->config['session_handle'] = $oauthSession['oauth_session_handle'];
if (isset($_REQUEST['accounts'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Accounts', 'core'), array('Where' => $_REQUEST['where']));
if ($XeroOAuth->response['code'] == 200) {
$accounts = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($accounts->Accounts[0]). " accounts in this Xero organisation, the first one is: ";
pr($accounts->Accounts[0]->Account);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['payments'])) {
if (!isset($_REQUEST['method'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Payments', 'core'), array('Where' => 'Status=="AUTHORISED"'));
if ($XeroOAuth->response['code'] == 200) {
$payments = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($payments->Payments[0]). " payments in this Xero organisation, the first one is: ";
pr($payments->Payments[0]->Payment);
} else {
outputError($XeroOAuth);
}
} elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "post" && $_REQUEST['payments']== 1 ) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Payments', 'core'), array('Where' => 'Status=="AUTHORISED"'));
if ($XeroOAuth->response['code'] == 200) {
$payment = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
if(count($payment->Payments[0]) > 0){
echo "Deleting the first available payment with ID: " . $payment->Payments[0]->Payment->PaymentID . "";
}
}
$xml = "
DELETED
";
$response = $XeroOAuth->request('POST', $XeroOAuth->url('Payments/'.$payment->Payments[0]->Payment->PaymentID, 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$payments = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo count($payments->Payments[0]). " payment deleted in this Xero organisation: ";
pr($payments->Payments[0]->Payment);
} else {
outputError($XeroOAuth);
}
}
}
if (isset($_REQUEST['accountsfilter'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Accounts', 'core'), array('Where' => 'Type=="BANK"'));
if ($XeroOAuth->response['code'] == 200) {
$accounts = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($accounts->Accounts[0]). " accounts in this Xero organisation, the first one is: ";
pr($accounts->Accounts[0]->Account);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['payrollemployees'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Employees', 'payroll'), array());
if ($XeroOAuth->response['code'] == 200) {
$employees = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($employees->Employees[0]). " employees in this Xero organisation, the first one is: ";
pr($employees->Employees[0]->Employee);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['payrollsuperfunds'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('SuperFunds', 'payroll'), array());
if ($XeroOAuth->response['code'] == 200) {
$superfunds = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($superfunds->SuperFunds[0]). " superfunds in this Xero organisation, the first one is: ";
pr($superfunds->SuperFunds[0]->SuperFund);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['payruns'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('PayRuns', 'payroll'), array('Where' => $_REQUEST['where']));
if ($XeroOAuth->response['code'] == 200) {
$accounts = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($accounts->PayRuns[0]). " PayRuns in this Xero organisation, the first one is: ";
pr($accounts->PayRuns[0]->PayRun);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['timesheets'])) {
$xml = "
5e493b2e-c3ed-4172-95b2-593438101f76
2015-04-13T00:00:00
2015-04-20T00:00:00
Draft
";
$response = $XeroOAuth->request('POST', $XeroOAuth->url('Timesheets', 'payroll'), array(), $xml, 'xml');
if ($XeroOAuth->response['code'] == 200) {
$timesheets = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($timesheets->Timesheets[0]). " Timesheet created in this Xero organisation, the first one is: ";
pr($timesheets->Timesheets[0]->Timesheet);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['superfundproducts'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('SuperFundProducts', 'payroll'), array('ABN' => $_REQUEST['where']));
if ($XeroOAuth->response['code'] == 200) {
$accounts = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($accounts->SuperFundProducts[0]). " SuperFundProducts in this Xero organisation, the first one is: ";
pr($accounts->SuperFundProducts[0]->SuperFundProduct[0]);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['invoice'])) {
if (!isset($_REQUEST['method'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoices', 'core'), array('order' => 'Total DESC'));
if ($XeroOAuth->response['code'] == 200) {
$invoices = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($invoices->Invoices[0]). " invoices in this Xero organisation, the first one is: ";
pr($invoices->Invoices[0]->Invoice);
if ($_REQUEST['invoice']=="pdf") {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoice/'.$invoices->Invoices[0]->Invoice->InvoiceID, 'core'), array(), "", 'pdf');
if ($XeroOAuth->response['code'] == 200) {
$myFile = $invoices->Invoices[0]->Invoice->InvoiceID.".pdf";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $XeroOAuth->response['response']);
fclose($fh);
echo "PDF copy downloaded, check your the directory of this script.";
} else {
outputError($XeroOAuth);
}
}
} else {
outputError($XeroOAuth);
}
} elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "put" && $_REQUEST['invoice']== 1 ) {
$xml = "
ACCREC
Martin Hudson
2013-05-13T00:00:00
2013-05-20T00:00:00
Exclusive
Monthly rental for property at 56a Wilkins Avenue
4.3400
395.00
200
";
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('Invoices', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$invoice = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . count($invoice->Invoices[0]). " invoice created in this Xero organisation.";
if (count($invoice->Invoices[0])>0) {
echo "The first one is: ";
pr($invoice->Invoices[0]->Invoice);
}
} else {
outputError($XeroOAuth);
}
} elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "4dp" && $_REQUEST['invoice']== 1 ) {
$xml = "
ACCREC
Steve Buscemi
2014-05-13T00:00:00
2014-05-20T00:00:00
Exclusive
Monthly rental for property at 56b Wilkins Avenue
4.3400
395.6789
200
";
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('Invoices', 'core'), array('unitdp' => '4'), $xml);
if ($XeroOAuth->response['code'] == 200) {
$invoice = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . count($invoice->Invoices[0]). " invoice created in this Xero organisation.";
if (count($invoice->Invoices[0])>0) {
echo "The first one is: ";
pr($invoice->Invoices[0]->Invoice);
}
} else {
outputError($XeroOAuth);
}
} elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "post" ) {
$xml = "
ACCREC
Martin Hudson
2013-05-13T00:00:00
2013-05-20T00:00:00
Exclusive
Monthly rental for property at 56a Wilkins Avenue
4.3400
395.00
200
";
$response = $XeroOAuth->request('POST', $XeroOAuth->url('Invoices', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$invoice = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . count($invoice->Invoices[0]). " invoice created in this Xero organisation.";
if (count($invoice->Invoices[0])>0) {
echo "The first one is: ";
pr($invoice->Invoices[0]->Invoice);
}
} else {
outputError($XeroOAuth);
}
}elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "put" && $_REQUEST['invoice']=="attachment" ) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoices', 'core'), array('Where' => 'Status=="DRAFT"'));
if ($XeroOAuth->response['code'] == 200) {
$invoices = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($invoices->Invoices[0]). " draft invoices in this Xero organisation, the first one is: ";
pr($invoices->Invoices[0]->Invoice);
if ($_REQUEST['invoice']=="attachment") {
$attachmentFile = file_get_contents('http://i.imgur.com/mkDFLf2.png');
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('Invoice/'.$invoices->Invoices[0]->Invoice->InvoiceID.'/Attachments/image.png', 'core'), array(), $attachmentFile, 'file');
if ($XeroOAuth->response['code'] == 200) {
echo "Attachment successfully created against this invoice.";
} else {
outputError($XeroOAuth);
}
}
} else {
outputError($XeroOAuth);
}
}
}
if (isset($_REQUEST['invoicesfilter'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoices', 'core'), array('Where' => 'Contact.Name.Contains("Martin")'));
if ($XeroOAuth->response['code'] == 200) {
$accounts = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($accounts->Invoices[0]). " matching invoices in this Xero organisation, the first one is: ";
pr($accounts->Invoices[0]->Invoice);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['invoicesmodified'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoices', 'core'), array('If-Modified-Since' => gmdate("M d Y H:i:s",(time() - (1 * 24 * 60 * 60)))));
if ($XeroOAuth->response['code'] == 200) {
$accounts = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($accounts->Invoices[0]). " matching invoices in this Xero organisation, the first one is: ";
pr($accounts->Invoices[0]->Invoice);
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['banktransactions'])) {
if (!isset($_REQUEST['method'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('BankTransactions', 'core'), array(), "", "xml");
if ($XeroOAuth->response['code'] == 200) {
$banktransactions = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($banktransactions->BankTransactions[0]). " bank transactions in this Xero organisation.";
if (count($banktransactions->BankTransactions[0])>0) {
echo "The first one is: ";
pr($banktransactions->BankTransactions[0]->BankTransaction);
}
} else {
outputError($XeroOAuth);
}
} elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "put" ) {
$xml = "
SPEND
Westpac
2013-04-16T00:00:00
Yearly Bank & Account Fee
1.0000
20.00
400
090
";
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('BankTransactions', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$banktransactions = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($banktransactions->BankTransactions[0]). " successful bank transaction(s) created in this Xero organisation.";
if (count($banktransactions->BankTransactions[0])>0) {
echo "The first one is: ";
pr($banktransactions->BankTransactions[0]->BankTransaction);
}
} else {
outputError($XeroOAuth);
}
}
}
if( isset($_REQUEST['contacts'])) {
if (!isset($_REQUEST['method'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Contacts', 'core'), array());
if ($XeroOAuth->response['code'] == 200) {
$contacts = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($contacts->Contacts[0]). " contacts in this Xero organisation, the first one is: ";
pr($contacts->Contacts[0]->Contact);
} else {
outputError($XeroOAuth);
}
} elseif(isset($_REQUEST['method']) && $_REQUEST['method'] == "post" ){
$xml = "
Matthew and son
emailaddress@yourdomain.com
matthewson_test99
Matthew
Masters
";
$response = $XeroOAuth->request('POST', $XeroOAuth->url('Contacts', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$contact = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . count($contact->Contacts[0]). " contact created/updated in this Xero organisation.";
if (count($contact->Contacts[0])>0) {
echo "The first one is: ";
pr($contact->Contacts[0]->Contact);
}
} else {
outputError($XeroOAuth);
}
}elseif(isset($_REQUEST['method']) && $_REQUEST['method'] == "put" ){
$xml = "
Orlena Greenville
";
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('Contacts', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$contacts = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($contacts->Contacts[0]). " successful contact(s) created in this Xero organisation.";
if(count($contacts->Contacts[0])>0){
echo "The first one is: ";
pr($contacts->Contacts[0]->Contact);
}
} else {
outputError($XeroOAuth);
}
}
}
if( isset($_REQUEST['items'])) {
if (!isset($_REQUEST['method'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Items', 'core'), array());
if ($XeroOAuth->response['code'] == 200) {
$items = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($items->Items[0]). " items in this Xero organisation, the first one is: ";
pr($items->Items[0]->Item);
} else {
outputError($XeroOAuth);
}
} elseif(isset($_REQUEST['method']) && $_REQUEST['method'] == "put" ){
$xml = "
-
ITEM-CODE-01
";
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('Items', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$item = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . count($item->Items). " item created in this Xero organisation. ";
if (count($item->Items[0])>0) {
echo "The item is: ";
pr($item->Items[0]->Item);
}
} else {
outputError($XeroOAuth);
}
}
}
if (isset($_REQUEST['organisation'])&&$_REQUEST['request']=="") {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Organisation', 'core'), array('page' => 0));
if ($XeroOAuth->response['code'] == 200) {
$organisation = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "Organisation name: " . $organisation->Organisations[0]->Organisation->Name;
} else {
outputError($XeroOAuth);
}
}elseif (isset($_REQUEST['organisation'])&&$_REQUEST['request']=="json") {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Organisation', 'core'), array(), $xml, 'json');
if ($XeroOAuth->response['code'] == 200) {
$organisation = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
$json = json_decode(json_encode($organisation),true);
echo "Organisation name: " . $json['Organisations'][0]['Name'];
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['trialbalance'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Reports/TrialBalance', 'core'), array('page' => 0));
if ($XeroOAuth->response['code'] == 200) {
$report = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "Organisation name: " . $report->Organisations[0]->Organisation->Name;
} else {
outputError($XeroOAuth);
}
}
if (isset($_REQUEST['trackingcategories'])) {
if (!isset($_REQUEST['method'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('TrackingCategories', 'core'), array('page' => 0));
if ($XeroOAuth->response['code'] == 200) {
$tracking = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($tracking->TrackingCategories[0]). " tracking categories in this Xero organisation, the first with ". count($tracking->TrackingCategories[0]->TrackingCategory->Options) ." options. ";
echo "The first one has tracking category name: " . $tracking->TrackingCategories[0]->TrackingCategory->Name;
echo "The first option in that category is: " . $tracking->TrackingCategories[0]->TrackingCategory->Options->Option[0]->Name;
} else {
outputError($XeroOAuth);
}
}elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "getarchived") {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('TrackingCategories', 'core'), array('includeArchived' => 'true'));
if ($XeroOAuth->response['code'] == 200) {
$tracking = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($tracking->TrackingCategories[0]). " tracking categories in this Xero organisation, the first with ". count($tracking->TrackingCategories[0]->TrackingCategory->Options) ." options. ";
echo "The first one has tracking category name: " . $tracking->TrackingCategories[0]->TrackingCategory->Name;
echo "The first option in that category is: " . $tracking->TrackingCategories[0]->TrackingCategory->Options->Option[0]->Name;
} else {
outputError($XeroOAuth);
}
}elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "put" && $_REQUEST['trackingcategories']== 1 ) {
$xml = "
Salespersons
ACTIVE
";
$response = $XeroOAuth->request('PUT', $XeroOAuth->url('TrackingCategories', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$tracking = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . count($tracking->TrackingCategories[0]). " tracking created in this Xero organisation.";
if (count($tracking->TrackingCategories[0])>0) {
echo "The first one is: ";
pr($tracking->TrackingCategories[0]->TrackingCategory);
}
} else {
outputError($XeroOAuth);
}
}elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "archive" && $_REQUEST['trackingcategories']== 1 ) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('TrackingCategories', 'core'), array());
if ($XeroOAuth->response['code'] == 200) {
$tracking = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($tracking->TrackingCategories[0]). " tracking categories in this Xero organisation. ";
if(count($tracking->TrackingCategories[0]) > 0){
echo "The first one has tracking category name: " . $tracking->TrackingCategories[0]->TrackingCategory->Name;
echo ", and will be archived.";
}
}
$xml = "
".$tracking->TrackingCategories[0]->TrackingCategory->Name."
".$tracking->TrackingCategories[0]->TrackingCategory->TrackingCategoryID."
ARCHIVED
";
if(count($tracking->TrackingCategories[0]) > 0){
$response = $XeroOAuth->request('POST', $XeroOAuth->url('TrackingCategories', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$tracking = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . count($tracking->TrackingCategories[0]). " tracking archived in this Xero organisation.";
if (count($tracking->TrackingCategories[0])>0) {
echo "The first one is: ";
pr($tracking);
}
} else {
outputError($XeroOAuth);
}
}
}elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "restore" && $_REQUEST['trackingcategories']== 1 ) {
$xml = "
Region
ACTIVE
";
$response = $XeroOAuth->request('POST', $XeroOAuth->url('TrackingCategories', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$tracking = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . count($tracking->TrackingCategories[0]). " tracking restored in this Xero organisation.";
if (count($tracking->TrackingCategories[0])>0) {
echo "The first one is: ";
pr($tracking->TrackingCategories[0]);
}
} else {
outputError($XeroOAuth);
}
}
}
if (isset($_REQUEST['folders'])) {
if (!isset($_REQUEST['method'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Folders', 'file'), array());
if ($XeroOAuth->response['code'] == 200) {
$folders = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($folders). " folders in this Xero organisation, the first one is: ";
pr($folders->Folder[0]);
} else {
outputError($XeroOAuth);
}
}elseif (isset($_REQUEST['method']) && $_REQUEST['method'] == "files" && $_REQUEST['folders']== 1 ) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Folders', 'file'), array());
if ($XeroOAuth->response['code'] == 200) {
$folder = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "There are " . count($folder). " folders in this Xero organisation. ";
if(count($folder->Folder[0]) > 0){
echo "The first one has the name: " . $folder->Folder[0]->Name;
echo ", and will be checked for files.";
}
}
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Folders/'.$folder->Folder[0]->Id.'/Files', 'file'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
$folders = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
echo "" . $folders->FileCount. " files in this folder.";
if (count($folders->Files[0])>0) {
echo "The first one is: ";
pr($folders->Files[0]->Items[0]->File[0]);
}
} else {
outputError($XeroOAuth);
}
}
}
if (isset($_REQUEST['multipleoperations'])) {
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Organisation', 'core'), array('page' => 0));
if ($XeroOAuth->response['code'] == 200) {
} else {
outputError($XeroOAuth);
}
$xml = "
Test group
ACTIVE
";
$response = $XeroOAuth->request('POST', $XeroOAuth->url('ContactGroups', 'core'), array(), $xml);
if ($XeroOAuth->response['code'] == 200) {
} else {
outputError($XeroOAuth);
}
$response = $XeroOAuth->request('GET', $XeroOAuth->url('ContactGroups', 'core'), array('page' => 0));
if ($XeroOAuth->response['code'] == 200) {
} else {
outputError($XeroOAuth);
}
}
}