【发布时间】:2017-03-14 08:10:31
【问题描述】:
我想将 xero 集成到我的 codeigniter(PHP) 站点。你能请任何人帮助我吗?是否有任何公共类型的 xero api 库。
谢谢
【问题讨论】:
标签: php json xml codeigniter
我想将 xero 集成到我的 codeigniter(PHP) 站点。你能请任何人帮助我吗?是否有任何公共类型的 xero api 库。
谢谢
【问题讨论】:
标签: php json xml codeigniter
Xero API Link - 希望对您有所帮助。我已经使用这个 Git hub 链接实现了 Xero api。我们可以在 laravel 框架或 codeigniter 框架中部署和使用这个库。我在 laravel 框架中使用,您可以使用私有类型或公共类型。
首先配置私有应用程序设置。
<?php
namespace XeroPHP\Application;
require '';
use XeroPHP\Application;
use XeroPHP\Models\Accounting\Invoice;
class PrivateApplication extends Application
{
/**
* @param array $config
*/
public function __construct()
{
$key = file_get_contents("file://privatekey.pem");
$config = [
'oauth' => [
'callback' => 'http://localhost/',
'consumer_key' => '',
'consumer_secret' => '',
'rsa_private_key' => $key,
],
];
//As we don't need to Authorize/RequestToken, it's populated here.
$config['oauth']['token'] = $config['oauth']['consumer_key'];
parent::__construct($config);
}
}
然后为privateApplication创建Object,然后使用它。
public function get()
{
$xero = new PrivateApplication();
$startDateString = date('Y, m, d');
$endDateString = date('Y, m, d', strtotime('-30 days'));
$invoices = $xero->load(Invoice::class)
->orderBy("Date", "DESC")
->where(sprintf('Date >= DateTime(%s)', $endDateString))
->where('Status', Invoice::INVOICE_STATUS_AUTHORISED)
->where('Type', Invoice::INVOICE_TYPE_ACCREC)
->execute();
return $invoices;
}
【讨论】: