定制 digfish/ivx-api2-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

digfish/ivx-api2-php

Composer 安装命令:

composer require digfish/ivx-api2-php

包简介

PHP client implementation of InvoiceXpress API using new json-based API 2.0

README 文档

README

Is no more than a simple PHP wrapper for making requests with the InvoiceXpress API. It's a fork of the original WidgiLabs/InvoiceXpressRequest-PHP-API, coded by nunomorgadinho.

Made compatible with the new API version 2.0 that now natively responds with JSON format.

This code can be perhaps very low level to the impatient, if you feel that after taking a look at it, and you are a fan of Laravel, as I am too, I would recommend to you as an alternative to take a look at the invoicexpress-api by rpsimao.

If you intend to use this code in a project of yours, I show below some examples on how can be used.

With the following class, which extends the class in InvoiceXpressRequest.php :

use digfish\ivx_api2_php\InvoiceXpressRequest;

<?php class MyInvoiceXpressApi extends InvoiceXpressRequest
{
    public static function init($domain, $token)   {
        parent::init($domain, $token);
    }

    public function __construct($method) {
        self::init(IVX_DOMAIN,IVX_TOKEN);
        parent::__construct($method);
    }

    public function invoke($args = array(), $debug = false)    {
        $this->post($args);
        echo "** Invoking {$this->_method} **\n ";
        $response = $this->getResponse();
        $this->request();

        if (!$this->success()) {
            echo "Something got wrong!\n";
            echo "ERRORS:\n";
            var_dump($this->getError());
        }
        return $response;
    }
}

You should already have assigned values to the IVX_DOMAIN and IVX_TOKEN . If, for example you are using myFirm as the name for your company you should use that name. The IVX_TOKEN is the API Key you can obtain at the InvoiceXpress backoffice in Account >> Integrations >> API .

You can then assign to them:

  define('IVX_DOMAIN','myFirm');
  define('IVX_TOKEN','--- the API key with 40 chars here ----');

You can put these two lines on a separate file with the adequate permissions to not be world-readable and include it in the header of the file of the example code above.

Then, to invoke your new class to get data, like listing invoices, you can do:

  $api = new MyInvoiceXpressApi ( 'invoices.list' );
  $response = $api->invoke($args);

$args is an associative PHP array with the parameters you pass to the API like for example the page number:

 $args['page'] = 3;

The API response should be in the $response variable, which contains a PHP array with the invoice data.

Some things are not implemented

Only the methods to list and manipulate Invoices, Clients and access the Invoice Items are available. Methods that use other things like Estimates, Guides, Purchase Orders, Sequences, Taxes and Accounts were not implemented (yet). Some methods that require that the args are passed through JSON as request (and don't use HTTP GET method) to the API server are still to be implemented.

Implementation project

Have a look at the ivxapi project, which provides a example case of use of this library, along with unitary tests.

digfish/ivx-api2-php 适用场景与选型建议

digfish/ivx-api2-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 digfish/ivx-api2-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 27
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-02