venturecraft/xero-laravel

Laravel 4 的 Xero 服务提供者

dev-master 2015-04-13 06:38 UTC

This package is auto-updated.

Last update: 2024-09-23 14:44:14 UTC


README

最初从 https://github.com/Softlabs/xero-laravel 分支而来

一个简单的 Laravel 4 服务提供者,用于包含 PHP Xero API

安装

可以通过 Composer 安装 Xero 服务提供者,要求 Venturecraft/xero-laravel 包,并在你的项目的 composer.json 中设置 minimum-stabilitydev

{
	"require": {
		"laravel/framework": "4.0.*",
		"venturecraft/xero-laravel": "dev-master"
	},
	"minimum-stability": "dev"
}

使用方法

要使用 Xero 服务提供者,你必须在启动 Laravel 应用程序时注册提供者。

使用 Laravel 配置

创建一个新的 app/config/xero.php 配置文件,包含以下选项

return array(
    'key'           => '<your-xero-key>',
    'secret'        => '<your-xero-secret>',
    'publicPath'    => '../app/config/xero/publickey.cer',
    'privatePath'   => '../app/config/xero/privatekey.pem'
);

app/config/app.php 中找到 providers 键并注册 Xero 服务提供者。

    'providers' => array(
        // ...
        'Venturecraft\XeroLaravel\XeroLaravelServiceProvider',
    )

app/config/app.php 中找到 aliases 键并添加我们的 Xero 别名。

    'aliases' => array(
        // ...
        'XeroLaravel' 	  => 'Venturecraft\XeroLaravel\Facades\XeroLaravel',
    )

设置应用程序

创建公钥和私钥,并将它们保存到 /app/config/xero/ 中,分别为 publickey.cer 和 privatekey.pem。

有关设置密钥的更多信息,请参阅 Xero 文档

示例用法

创建联系人

$contact = array(
    array(
       	"Name"        => $user['company']['name'],
       	"FirstName"   => $user['firstname'],
		"LastName"    => $user['surname'],
	)
);

$xero_contact = XeroLaravel::Contacts($contact);

使用 WHERE 子句和分页获取联系人

$where = "ContactNumber!=null&IsCustomer=true";
$page  = 1;
print_r(XeroLaravel::Contacts(false, false, $where, false, $page));

参考