slightlydiff/yii2-xero 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

slightlydiff/yii2-xero

Composer 安装命令:

composer require slightlydiff/yii2-xero

包简介

An extension for using the Xero API from within Yii2

README 文档

README

An extension for using the Xero API from within Yii2.

This extension is based on Xero's XeroOAuth-PHP code at https://github.com/XeroAPI/XeroOAuth-PHP

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist slightlydiff/yii2-xero "*"

or add

"slightlydiff/yii2-xero": "*"

to the require section of your composer.json file.

Configuration

Add the following to your application conmfiguration file:

        'xeroApi' => [
            'class' => 'slightlydiff\xero\XeroApi',
            'rsa_public_key' => '@app/config/certs/xero_publickey.cer',
            'rsa_private_key' => '@app/config/certs/xero_privatekey.pem',
            'consumer_key' => 'yourconsumerkey',
            'shared_secret' => 'yoursharedsecret',
            'useragent' => 'XeroOAuth-PHP'
        ],

modifying the above for your own Xero consumer key, shared secret and the path to you public / private key pair.

Usage

For a GET request:

  • The first parameter is the only required parameter and must be 'GET', 'POST', 'PUT' or 'DELETE'
  • The second parameter can be FALSE or a string ID if you want to get a single record by ID
  • The third parameter can be a date/time, in any format, if you want to fetch all records modified since that date
  • The fourth parameter can be an array of filters as described at https://developer.xero.com/documentation/getting-started/http-requests-and-responses/. This allows you to filter the query and order the returned data.

All parameters are optional except the first. If not parameters are passed then all records of the requested type will be returned

For a POST or PUT request:

  • The first parameter must be the method, as above, and the second param must be a multidimensional array of the data being passed as in the examples below.

To create a contact see https://developer.xero.com/documentation/api/contacts/ for the format and apply as follows:

$new_contact = array(
    array(
        "Name" => "Joe Bloggs",
        "FirstName" => "Joe",
        "LastName" => "Bloggs",
        "Addresses" => array(
            "Address" => array(
                array(
                    "AddressType" => "POSTAL",
                    "AddressLine1" => "123 Anystreet",
                    "City" => "Anytown",
                    "PostalCode" => "1234"
                ),
                array(
                    "AddressType" => "STREET",
                    "AddressLine1" => "123 Anystreet",
                    "City" => "Anytown",
                    "PostalCode" => "1234"
                )
            )
        )
    )
);
$result = $xero->Contacts('POST', $new_invoice);

To create a invoice or credit note see https://developer.xero.com/documentation/api/invoices/ for the format and apply as follows:

$new_invoice = array(
    array(
        "Type"=>"ACCREC",
        "Contact" => array(
            "ContactID" => "[contact id]"
        ),
        "Date" => "2016-08-01",
        "DueDate" => "2016-08-30",
        "Status" => "SUBMITTED",
        "LineAmountTypes" => "Exclusive",
        "LineItems"=> array(
            "LineItem" => array(
                array(
                    "Description" => "Some product description",
                    "Quantity" => "1.0000",
                    "UnitAmount" => "123.00",
                    "AccountCode" => "200"
                )
            )
        )
    )
);
$result = $xero->Invoices('POST', $new_invoice);

To create a payment see https://developer.xero.com/documentation/api/payments/ for the format and apply as follows:

$new_payment = array(
    array(
        "Invoice" => array(
            "InvoiceNumber" => "INV-1234"
        ),
        "Account" => array(
            "Code" => "[account code]"
        ),
        "Date" => "2016-08-30",
        "Amount"=>"123.00",
    )
);
$result = $xero->Payments('POST', $new_payment);

To get details of an account with the name "Joe Bloggs"

$result = $xero->Accounts('GET', false, false, array("Name"=>"Joe Bloggs") );

See https://developer.xero.com/documentation/api/accounts/ for a list of all parameters.

To get details of all contacts

$result = $xero->Contacts;

To get details of all contacts modified in the last 24 hours

$result = $xero->Contacts('GET', false, gmdate("M d Y H:i:s", (time() - (1 * 24 * 60 * 60))), false);

To get details of a contact by ID

$result = $xero->Contacts('GET', 'contact id here', false, false);

To get details of all contacts whos name contains "Bloggs" and order the results by Name

$result = $xero->Contacts('GET', false, false, ['where' => 'Name.Contains("Bloggs")', 'order' => 'Name DESC']);

slightlydiff/yii2-xero 适用场景与选型建议

slightlydiff/yii2-xero 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.59k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 08 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「extension」 「yii2」 「xero」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 slightlydiff/yii2-xero 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 slightlydiff/yii2-xero 我们能提供哪些服务?
定制开发 / 二次开发

基于 slightlydiff/yii2-xero 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 15.59k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-08-23