3.1.4 新增或修改貨物 (PHP)

新增貨物

新增貨物範例程式
<?php function processShipments($url, $data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $res = curl_exec($ch); curl_close($ch); return $res; } function pgwApiDate($myDate) { $dateTime = DateTime::createFromFormat('Y-m-d H:i:s', $myDate); $requiredJsonFormat = sprintf('/Date(%s%s)/', $dateTime->format('U') * 1000, $dateTime->format('O')); return $requiredJsonFormat; } $sandbox_url = "https://sandbox.unixus.com.my/api/EzLabel/Client/Shipments.svc/Json/ProcessShipments"; $production_url = "https://api.unixus.com.my/EzLabel/Client/Shipments.svc/Json/ProcessShipments"; $data = ' { "_shipmentsParameter" : { "ActionType" : "0", "ShipmentsCredentials" : { "CultureType" : "0", "Password" : "password", "UserName" : "username" }, "ShipperInfo" : { "ShipperName" : "Unixus Solutions Sdn. Bhd.", "ContactPerson" : "IT Department", "Address1" : "46-02 JALAN TUN ABDUL RAZAK,", "Address2" : "SUSUR 1,", "Address3" : "", "PostCode" : "80000", "City" : "JOHOR BHARU", "State" : "JOHOR", "CountryCode" : "MY", "StationCode" : "", "Phone1" : "607-2222668", "Phone2" : "", "MobilePhone" : "", "Fax" : "", "Email" : "[email protected]", "Url" : "" }, "ConsigneeInfo" : { "ConsigneeName" : "LWE (AU) Ltd.", "ContactPerson" : "Mr. Ng", "IdentityNo" : "0123abcd", "Address1" : "Test Address 1", "Address2" : "Test Address 2", "Address3" : "", "PostCode" : "70000", "City" : "JOHOR BHARU", "State" : "JOHOR", "CountryCode" : "MY", "StationCode" : "", "Phone1" : "60-7-2222668", "Phone2" : "", "MobilePhone" : "", "Fax" : "", "Email" : "[email protected]", "Url" : "http://www.lwe.com.hk" }, "CustomerCode" : "300001", "ProfitCentreCode" : "", "ShipmentDate" : "/Date(1510641435000+0800)/", "HawbNo" : "", "ReferenceNo" : "123456", "ReferenceAgent" : "", "TOSMode" : "MY-E-EXPRESS", "PackageType" : "0", "NatureOfGoods" : "SHOES", "NoOfPieces" : "1", "WeightType": 0, "CurrencyCode": "AUD", "Remarks" : "The shipment easy to broke, please becareful.", "WeightInfo" : [ { "PackageReference" : "PKG01", "PackageHeight" : "1", "PackageLength" : "1", "PackageWidth" : "1", "ActualWeight" : "5" } ], "ItemInfo" : [ { "ItemReference" : "LADIES SHOES", "NoOfUnit" : "3", "ItemValue" : "15" } ], "TagsInfo" : [ { "TagCode" : "TAG1", "TagValue" : "ANY EXTRA INFORMATION" } ], "Submitted_Date" : "/Date(1510641435000+0800)/" } } '; $response = processShipments($sandbox_url, $data); var_dump($response); ?>

修改貨物

修改貨物範例程式
<?php function processShipments($url, $data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $res = curl_exec($ch); curl_close($ch); return $res; } function pgwApiDate($myDate) { $dateTime = DateTime::createFromFormat('Y-m-d H:i:s', $myDate); $requiredJsonFormat = sprintf('/Date(%s%s)/', $dateTime->format('U') * 1000, $dateTime->format('O')); return $requiredJsonFormat; } $sandbox_url = "https://sandbox.unixus.com.my/api/EzLabel/Client/Shipments.svc/Json/ProcessShipments"; $production_url = "https://api.unixus.com.my/EzLabel/Client/Shipments.svc/Json/ProcessShipments"; $data = ' { "_shipmentsParameter" : { "ActionType" : "1", "ShipmentsCredentials" : { "CultureType" : "0", "Password" : "password", "UserName" : "username" }, "ShipperInfo" : { "ShipperName" : "Unixus Solutions Sdn. Bhd.", "ContactPerson" : "IT Department", "Address1" : "46-02 JALAN TUN ABDUL RAZAK,", "Address2" : "SUSUR 1,", "Address3" : "", "PostCode" : "80000", "City" : "JOHOR BHARU", "State" : "JOHOR", "CountryCode" : "MY", "StationCode" : "", "Phone1" : "607-2222668", "Phone2" : "", "MobilePhone" : "", "Fax" : "", "Email" : "[email protected]", "Url" : "" }, "ConsigneeInfo" : { "ConsigneeName" : "LWE (AU) Ltd.", "ContactPerson" : "Mr. Ng", "IdentityNo" : "0123abcd", "Address1" : "Test Address 1", "Address2" : "Test Address 2", "Address3" : "", "PostCode" : "70000", "City" : "JOHOR BHARU", "State" : "JOHOR", "CountryCode" : "MY", "StationCode" : "", "Phone1" : "60-7-2222668", "Phone2" : "", "MobilePhone" : "", "Fax" : "", "Email" : "[email protected]", "Url" : "http://www.lwe.com.hk" }, "CustomerCode" : "300001", "ProfitCentreCode" : "", "ShipmentDate" : "/Date(1510641435000+0800)/", "HawbNo" : "344010500000151", "ReferenceNo" : "123456", "ReferenceAgent" : "", "TOSMode" : "MY-E-EXPRESS", "PackageType" : "0", "NatureOfGoods" : "SHOES", "NoOfPieces" : "1", "WeightType": 0, "CurrencyCode": "AUD", "Remarks" : "The shipment easy to broke, please becareful.", "WeightInfo" : [ { "PackageReference" : "PKG01", "PackageHeight" : "1", "PackageLength" : "1", "PackageWidth" : "1", "ActualWeight" : "5" } ], "ItemInfo" : [ { "ItemReference" : "LADIES SHOES", "NoOfUnit" : "3", "ItemValue" : "15" } ], "TagsInfo" : [ { "TagCode" : "TAG1", "TagValue" : "ANY EXTRA INFORMATION" } ], "Submitted_Date" : "/Date(1510641435000+0800)/" } } '; $response = processShipments($sandbox_url, $data); var_dump($response); ?>
Copyright © 2018 Unixus Solutions Sdn. Bhd. All rights reserved.