定制 tow-com-au/sageone-php 二次开发

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

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

tow-com-au/sageone-php

Composer 安装命令:

composer require tow-com-au/sageone-php

包简介

SageOne Accounting API Wrapper (PHP)

README 文档

README

1. Overview

This is a simple API wrapper library for SageOne Accounting platform.

Official API Documentation & API sign up can be found at: https://accounting.sageone.co.za/Marketing/DeveloperProgram.aspx

Courtesy of the Tow.com.au team :) - https://www.tow.com.au

2. Installation

With composer, add to your composer.json :

{
    "require": {
        "tow-com-au/sageone-php": "dev-master"
    }
}

If you are new to composer, here is some simple steps to take.

  1. Download composer.phar from the above link
  2. Create a json file named composer.json containing just exactly the above "require" block
  3. Having composer.phar and composer.json side by side, you can run the command:
php ./composer.phar install
  1. The composer will create a directory named vendor and download all required libraries into it.

  2. In the vendor directory, there's also a file named autoload.php. This is the PHP autoloader for the libraries inside. You might need to register it to you existing autoloader, or include it manually.

3. Usage

To login to the SageOne API you will need two things. First, an 'AuthCode', which can be generated from your login details in the format base64_encode('username:password'), and second, an API key as requested from SageOne.

Create client library instance

// You will need to include this autoload script manually
// if you don't have any autoloader setup.
include "../path/to/vendor/autoload.php"; 

// Use your login to request an API key from:
// https://accounting.sageone.co.za/Marketing/DeveloperProgram.aspx
$apiKey = '{api key goes here}';
$authCode = base64_encode('username:password');

// SageOne will provide you with a localised endpoint url:
$apiEndpoint = 'https://accounting.sageone.com.au/api/1.1.1';

$companyId = false; // We don't have this yet

$debug = true;
$client = new Sage($apiEndpoint, $apiKey, $authCode, $companyId, $debug);

List your Company entities

$result = $client->listItems('Company');
if (!empty($result)) {
	// grab the first Company ID
	$companyId = $result[0]['ID'];
	// re-instantiate with $companyId
	$client = new Sage($apiEndpoint, $apiKey, $authCode, $companyId, $debug);
}

Create a Customer entity

// Create a customer
$customer_details = [
    'Name' => 'Test Customer',
    'Mobile' => '555-555',
    'CommunicationMethod' => 0,
    'Email' => 'test@test.com',
    'PostalAddress01' => '1 test street',
    'PostalAddress02' => 'testville',
    'PostalAddress03' => 'QLD',
    'PostalAddress04' => 4000,
    'PostalAddress05' => 'Australia',
    'TaxReference' => 'Customer 1',
];

// Save Customer entity
$result = $client->saveItem('Customer', $customer_details);

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-10-12