apih / easyparcel
EasyParcel Marketplace API的PHP封装器
dev-master
2019-03-14 10:15 UTC
Requires
- php: >=5.4
This package is not auto-updated.
Last update: 2024-09-29 23:09:46 UTC
README
EasyParcel API的PHP封装器。EasyParcel Marketplace API文档v2.0.0将需要详细说明如何传递方法中的参数。
依赖
- PHP 5.4.0+ (短数组语法)
- cURL
用法
- 在代码中包含文件
- 实例化EasyParcel客户端,并将API和认证密钥传递给构造函数
- 如果想要使用演示账号,请调用useDemo()方法
- 根据需要调用其他提供的方法
示例
代码
以下代码用于检查运输费率。
<?php // Include the file require 'EasyParcel.php'; // Define your API & authentication keys $api_key = 'something'; $auth_key = 'something'; // Instantiate EasyParcel client $easyparcel_client = new apih\EasyParcel\Client($api_key, $auth_key); // Call this method if you want to use demo account $easyparcel_client->useDemo(); // Data that should be passed into the method $bulk = [ [ 'pick_code' => '17000', 'pick_state' => 'Kelantan', 'pick_country' => 'MY', 'send_code' => '53100', 'send_state' => 'Kuala Lumpur', 'send_country' => 'MY', 'weight' => '0.5' ] ]; // Call checkRate() method $response = $easyparcel_client->checkRate($bulk); // Display the response echo json_encode($response); ?>
输出
以上代码的示例输出。
{
"api_status":"Success",
"error_code":"0",
"error_remark":"",
"result":[
{
"status":"Success",
"remarks":"",
"rates":[
{
"service_id":"EP-CS0I",
"service_name":"Next Day Delivery Service",
"service_type":"document",
"courier_id":"EP-CR0A",
"courier_name":"Poslaju",
"courier_logo":"http:\/\/cp.easyparcel.my\/v1\/include\/theme_1\/source\/img\/logo\/POS0006_POS_Laju_LOGO_ID_CMYK_140514.jpg",
"scheduled_start_date":"2017-06-23 Friday",
"pickup_date":"2017-06-22",
"delivery":"Estimated 2 working day(s)",
"price":"7.80",
"dropoff_point":[
]
},
{
"service_id":"EP-CS0F",
"service_name":"Next Day Delivery Service",
"service_type":"parcel",
"courier_id":"EP-CR0A",
"courier_name":"Poslaju",
"courier_logo":"http:\/\/cp.easyparcel.my\/v1\/include\/theme_1\/source\/img\/logo\/POS0006_POS_Laju_LOGO_ID_CMYK_140514.jpg",
"scheduled_start_date":"2017-06-23 Friday",
"pickup_date":"2017-06-22",
"delivery":"Estimated 2 working day(s)",
"price":"7.80",
"dropoff_point":[
]
},
{
"service_id":"EP-CS0N",
"service_name":"Next Day Delivery Service",
"service_type":"document",
"courier_id":"EP-CR05",
"courier_name":"Skynet",
"courier_logo":"http:\/\/cp.easyparcel.my\/v1\/include\/theme_1\/source\/img\/logo\/SKYNET-EXPRESS.png",
"scheduled_start_date":"2017-06-23 Friday",
"pickup_date":"2017-06-22",
"delivery":"Estimated 1 working day(s)",
"price":"7.80",
"dropoff_point":[
{
"point_id":"SKYNET_AKH",
"point_name":"SKYNET AYER KEROH",
"point_contact":"62316898",
"point_addr1":"SKYNET WORLDWIDE (MELAKA) SDN BHD",
"point_addr2":"653-O, Jalan Delima 3,",
"point_addr3":"Taman Bukit Melaka",
"point_addr4":"",
"point_postcode":"75450",
"point_city":"Bukit Beruang",
"point_state":"mlk",
"price":0
}
]
},
{
"service_id":"EP-CS0W",
"service_name":"Next Day Delivery Service",
"service_type":"parcel",
"courier_id":"EP-CR05",
"courier_name":"Skynet",
"courier_logo":"http:\/\/cp.easyparcel.my\/v1\/include\/theme_1\/source\/img\/logo\/SKYNET-EXPRESS.png",
"scheduled_start_date":"2017-06-23 Friday",
"pickup_date":"2017-06-22",
"delivery":"Estimated 1 working day(s)",
"price":"7.80",
"dropoff_point":[
{
"point_id":"SKYNET_AKH",
"point_name":"SKYNET AYER KEROH",
"point_contact":"62316898",
"point_addr1":"SKYNET WORLDWIDE (MELAKA) SDN BHD",
"point_addr2":"653-O, Jalan Delima 3,",
"point_addr3":"Taman Bukit Melaka",
"point_addr4":"",
"point_postcode":"75450",
"point_city":"Bukit Beruang",
"point_state":"mlk",
"price":0
}
]
},
{
"service_id":"EP-CS0E",
"service_name":"Next Day Delivery Service",
"service_type":"document",
"courier_id":"EP-CR0M",
"courier_name":"Nationwide",
"courier_logo":"http:\/\/cp.easyparcel.my\/v1\/include\/theme_1\/source\/img\/logo\/Nationwide-Express-logo.jpg",
"scheduled_start_date":"2017-06-23 Friday",
"pickup_date":"2017-06-22",
"delivery":"Estimated 1 working day(s)",
"price":"7.80",
"dropoff_point":[
]
},
{
"service_id":"EP-CS04",
"service_name":"Next Day Delivery Service",
"service_type":"parcel",
"courier_id":"EP-CR0M",
"courier_name":"Nationwide",
"courier_logo":"http:\/\/cp.easyparcel.my\/v1\/include\/theme_1\/source\/img\/logo\/Nationwide-Express-logo.jpg",
"scheduled_start_date":"2017-06-23 Friday",
"pickup_date":"2017-06-22",
"delivery":"Estimated 1 working day(s)",
"price":"7.80",
"dropoff_point":[
]
}
],
"pgeon_point":{
"Sender_point":[
],
"Receiver_point":[
]
}
}
]
}
许可证
这个库可以自由分发,并受MIT许可证的许可。