cektop7 / boxberry
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-10-01 11:03:13 UTC
README
通过composer安装的分支。
composer require cektop7/boxberry:dev-master
API.Boxberry
用于与Boxberry配送服务API交互的组件。这是一个通用的机制,可以简化与Boxberry API服务的集成。您无需深入研究SOAP和JSON,只需理解传递数据的结构即可。
组件安装
要从仓库安装源代码
$ git clone git@github.com:AlekseyNikulin/Boxberry.git
配置
为了配置应用程序,请修改配置文件 configure.php
// Корневая директория компонента. define("BOXBERRY_DIR",__DIR__."/"); // Адрес хоста источника данных. define("HOST","http://test.api.boxberry.de");
SOAP
如果您由于某些原因遇到curl的问题,禁用了allow_url_fopen等指令,那么您很可能会使用SOAP标准SOAP进行数据交换。
个人账户
在API个人账户中,您可以创建/修改/删除包裹,生成收据,生成标签等。
define("LC_SERVICE","/__soap/1c_lc.php?wsdl");
目录
在API目录中,您可以访问以下信息
- 有Boxberry(Boxberry订单提取点)的城市
- 有快递配送服务的城市
- 关于PВЗ(Boxberry订单提取点)的详细信息
- 提供服务的费用
- 计算配送费用
- 跟踪包裹状态
define("PUBLIC_SERVICE","/__soap/1c_public.php?wsdl");
Soap方法列表
必须指定方法属于哪个服务。如果不这样做,则将向未描述的方法传递参数,这些参数将被发送到PUBLIC_SERVICE服务。
$soap = [ LC_SERVICE=>[ 'ParselCreate', 'ParselCheck', 'ParselList', 'ParselDel', 'ParselStory', 'ParselSend', 'ParselSendStory', 'OrdersBalance', 'ParcelCreateForeign', 'ParcelSendForeign', 'PaymentOrders' ], PUBLIC_SERVICE=>[ 'ListCities', 'ListPoints', 'ListZips', 'ZipCheck', 'ListStatuses', 'ListStatusesFull', 'ListServices', 'PointsForParcels', 'CourierListCities', 'DeliveryCosts', 'DeliveryCostsF', 'PointsByPostCode', 'PointsDescription', 'ListPointsShort', 'ListCountry', 'ListPointsForeign' ] ];
JSON
通常JSON没有冗余,因此比SOAP更节省资源,更紧凑。SOAP中列出的所有方法和服务都在一个源中。如果使用JSON,则无需在SOAP设置中设置。
define("JSON_SERVICE","/json.php");
启动应用程序
请修改文件 index.php
包含配置文件
include_once(dirname(__FILE__)."/configure.php");
包含Boxberry类文件
include_once(BOXBERRY_DIR."/boxberry.php");
初始化Boxberry类
$boxberry = new \boxberryApi\boxberry();
数据传输类型:soap/json(小写)
$boxberry->type = "json";
方法期望和使用的参数列表
$boxberry->args = [ 'methodQuery' => 'get', 'token'=>'******', 'method'=>'ListPoints' ];
每个客户都会在注册Boxberry配送服务系统并签订合同后获得一个唯一的个人令牌(token)。传递"token"和"method"参数是必须的。
"methodQuery"只能有两个值 get/post。默认情况下,该组件使用POST请求。请注意,许多API方法实际上只使用GET请求。
获取结果
Boxberry类中的getData()方法返回从Boxberry API获取的数据数组
print_r($boxberry->getData());