digitalschmiede / fastbill
FastBill.com API 的包装器
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2021-11-21 17:30:07 UTC
README
#Fastbill
这是一个小的库,使用PHP可以与Fastbill API进行通信。这样您就可以在几步之内,以很少的前期知识来访问和操作您的Fastbill数据。
在 Fastbill-API 文档 中您可以找到各个请求的结构。这些请求必须以数组的形式传递给类。最简单的方法是参照文档中的 Request - JSON 示例。
##安装
绑定最新版本并使用您的Fastbill电子邮件和APIKey初始化fastbill类。
require("FastBill.php"); $fastbill = new \FastBill\FastBill(string $email, string $apiKey [, string $apiUrl = FASTBILL_PLUS]);
将 $email
替换为您Fastbill的电子邮件地址(例如 max@mustermann.de)并将 $apiKey
替换为您的Fastbill APIKey(例如 1238751bd8714ciafnafv3afubafeGizQnudJHBzfaiusbwt48)。如果您忘记了参数或这些参数为空,则 new fastbill()
将返回 False。
可选地,您可以作为3个参数传递APIURL。
或者通过Composer绑定包装器
{ "zweischneider/fastbill": "dev-master" }
##类
###调试模式
$fastbill->setDebug(bool $status = false);
使用这个类可以启用或禁用调试模式。默认情况下调试模式是禁用的。
一旦调试模式被激活,在发生错误时您将收到一个格式为: array("RESPONSE" => array("ERROR" => array("错误1","错误2",...)));
的数组。
###请求
$fastbill->request(array $request [, string $file]);
这个类期望一个包含请求数据的数组: Service [, Filter, Limit, Offset 和 Data]. 作为返回,您将收到一个数组,其中包含Fastbill的响应。如果发生错误,返回值为 False 或调试数组。
如果您想要传递一个文件,您可以提供服务器到所需文件的完整路径,或者在上传后传递 $_FILES[%parameter%]["tmp_name"]
.
##示例
###账单
// Als Rückgabe erhalten Sie alle Rechnungen $temp = $fastbill->request(array("SERVICE" => "invoice.get")); print_r($temp); // Hier alle Ausgangsrechnungen $temp = $fastbill->request(array("SERVICE" => "invoice.get", "FILTER" => array("TYPE" => "outgoing"))); print_r($temp); // Und hier die ersten drei Ausgangsrechnungen $temp = $fastbill->request(array("SERVICE" => "invoice.get", "FILTER" => array("TYPE" => "outgoing"), "LIMIT" => 3)); print_r($temp);
###客户
// Als Rückgabe erhalten Sie alle Kunden $temp = $fastbill->request(array("SERVICE" => "customer.get")); print_r($temp); // Hier den Kunden mit der ID 5376 $temp = $fastbill->request(array("SERVICE" => "invoice.get", "FILTER" => array("CUSTOMER_ID" => 5376))); print_r($temp);