pakkelabels / pakkelabels-php-sdk
v3.0.0
2018-11-15 14:09 UTC
Requires
- php: >=5.5.0
This package is not auto-updated.
Last update: 2019-08-30 06:44:45 UTC
README
此库已弃用。请使用 shipmondo_php_sdk 进行任何未来的更新。
此 SDK 支持 Pakkelabels.dk API v3。
规范: https://app.pakkelabels.dk/api/public/v3/specification
支持 Pakkelabels.dk API v2 的先前 SDK 可以在 for_api_v2 分支下找到
入门
下面是一个简单的 PHP 脚本,展示了启动所需的最低代码量。
<?php try { $client = new Pakkelabels('api_user', 'api_key'); } catch (PakkelabelsException $e) { echo $e->getMessage(); } ?>
创建 $client 对象后,您就可以开始使用 API 了。
示例
获取当前余额
<?php echo $client->account_balance(); ?>
获取未支付的付款请求
<?php $params = array( 'created_at_min' => '2017-06-19', 'page' => 1 ); echo $client->account_payment_requests($params); ?>
获取可用产品
<?php $params = array( 'country_code' => 'DK', 'carrier_code' => 'gls', 'page' => 1 ); echo $client->products($params); ?>
支持分页
获取可用/最近的取货点
<?php $params = array( 'country_code' => 'DK', 'carrier_code' => 'gls', 'zipcode' => '5000' ); echo $client->pickup_points($params); ?>
获取货运
<?php $params = array( 'page' => 1, 'carrier_code' => 'dao' ); echo $client->shipments($params); ?>
支持分页
按 ID 获取货运
<?php $id = 5545625; echo $client->shipment($id); ?>
获取货运的标签
<?php $shipment_id = 5545625; $params = array( 'label_format' => '10x19_pdf' ); echo $client->shipment_labels($shipment_id, $params); ?>
创建货运
<?php $params = array( "test_mode" => true, "own_agreement" => true, "label_format" => "a4_pdf", "product_code" => "GLSDK_HD", "service_codes" => "EMAIL_NT,SMS_NT", "order_id" => "10001", "reference" => "Webshop 10001", "sender" => array( "name" => "Pakkelabels.dk ApS", "address1" => "Strandvejen 6", "address2" => null, "country_code" => "DK", "zipcode" => "5240", "city" => "Odense NØ", "attention" => null, "email" => "firma@email.dk", "telephone" => "70400407", "mobile" => "70400407" ), "receiver" => array( "name" => "Lene Jensen", "address1" => "Vindegade 112", "address2" => null, "country_code" => "DK", "zipcode" => "5000", "city" => "Odense C", "attention" => null, "email" => "lene@email.dk", "telephone" => "50607080", "mobile" => "50607080", "instruction" => null ), "parcels" => array( array( "weight" => 1000 ) ), ); echo $client->create_shipment($params); ?>
获取货运监控状态
<?php $params = array( 'ids' => '5546689,5546696', 'page' => 1 ); echo $client->shipment_monitor_statuses($params); ?>
获取打印队列条目
<?php $params = array( 'page' => 1 ); echo print_r($client->print_queue_entries($params); ?>
获取退货门户
<?php $params = array( 'page' => 1 ); echo $client->return_portals($params); ?>
按 ID 获取退货门户
<?php $id = 4766; echo $client->return_portal($id); ?>
获取退货门户的退货货运
<?php $return_portal_id = 4766; $params = array( 'page' => 1 ); echo $client->return_portal_shipments($return_portal_id, $params); ?>
支持分页
获取导入的货运
<?php $params = array( 'page' => 1 ); echo $client->imported_shipments($params); ?>
支持分页
按 ID 获取导入的货运
<?php $id = 75545625; echo $client->imported_shipment($id); ?>
创建导入的货运
<?php $params = array( "carrier_code" => "gls", "product_code" => "GLSDK_HD", "service_codes" => "EMAIL_NT,SMS_NT", "order_id" => "10001", "reference" => "Webshop 10001", "sender" => array( "name" => "Pakkelabels.dk ApS", "address1" => "Strandvejen 6", "address2" => null, "country_code" => "DK", "zipcode" => "5240", "city" => "Odense NØ", "attention" => null, "email" => "firma@email.dk", "telephone" => "70400407", "mobile" => "70400407" ), "receiver" => array( "name" => "Lene Jensen", "address1" => "Vindegade 112", "address2" => null, "country_code" => "DK", "zipcode" => "5000", "city" => "Odense C", "attention" => null, "email" => "lene@email.dk", "telephone" => "50607080", "mobile" => "50607080", "instruction" => null ) ); echo $client->create_imported_shipment($params); ?>
按 ID 更新导入的货运
<?php $id = 75545625; $params = array( "carrier_code" => "gls", "product_code" => "GLSDK_HD", "service_codes" => "EMAIL_NT,SMS_NT", "order_id" => "10001", "reference" => "Webshop 10001", "sender" => array( "name" => "Pakkelabels.dk ApS", "address1" => "Strandvejen 6", "address2" => null, "country_code" => "DK", "zipcode" => "5240", "city" => "Odense NØ", "attention" => null, "email" => "firma@email.dk", "telephone" => "70400407", "mobile" => "70400407" ), "receiver" => array( "name" => "Lene Jensen", "address1" => "Vindegade 112", "address2" => null, "country_code" => "DK", "zipcode" => "5000", "city" => "Odense C", "attention" => null, "email" => "lene@email.dk", "telephone" => "50607080", "mobile" => "50607080", "instruction" => null ) ); echo $client->update_imported_shipment($id, $params); ?>
按 ID 删除/存档导入的货运
<?php $id = 75545625; echo $client->delete_imported_shipment($id); ?>