rtconner/freshbooks-api

FreshBooks API 的包装器

1.0 2016-11-24 04:51 UTC

This package is auto-updated.

Last update: 2024-09-04 15:35:06 UTC


README

PHP 对 FreshBooks API 的包装器。将 FreshBooks API 的 XML 结构简化为 PHP 数组结构。在创建新的 FreshBooksApi 实例时,您需要知道方法名称和参数。请参阅这里 http://developers.freshbooks.com/

Composer 安装

composer require rtconner/freshbooks-api dev-master

.. or ..

"require": {
    "rtconner/freshbooks-api": "dev-master"
}

示例代码

您在 FreshBooks API 页面上看到的 XML 标签参数是传递给 $fb->post() 的参数(作为一个数组)

$domain = 'your-subdomain'; // Do not include the URL scheme (https://). It will be added automatically
$token = '1234567890'; // your api token found in your account
$fb = new Freshbooks\FreshBooksApi($domain, $token); 

示例:列出邮箱为 some@email.com 的客户

// Method names are the same as found on the freshbooks API
$fb->setMethod('client.list');

// For complete list of arguments see FreshBooks docs at http://developers.freshbooks.com
$fb->post(array(
    'email' => 'some@email.com'
));

$fb->request();

if($fb->success()) {
	echo 'successful! the full response is in an array below';
	var_dump($fb->getResponse());
} else {
	echo $fb->getError();
	var_dump($fb->getResponse());
}

致谢