Geis Parcel API dla zautomatyzowania importu przesyłek - skrypt PHP
GEISPHP skrypt dła Geis G-Service CZ i SK / G-Service EN / G-Service PL
- Działa w PL, CZ, SK
- Importuje przesyłki
- Drukuje etykiety i protokoły
- Zbiera zamówienia
- i wykonuje wszystkie inne funkcje opisane w dokumencie G-Service
Nie trzeba już generować CSV, logować się do Geis, importować CSV i drukować etykiet!
O wszystko zadba API.
PHP 5.3+, PHP 7
Przykład zastosowania
<?php
/**
* Geis API - Usage Example
*/
require 'class_geis_v2.php';
try {
// you have to request access to G-Service, it is different from GClient Web
$G = new Geis(
$clientNumber = '70905941', $clientPassword = 'ws15511',
$service = 'CZ', // other values: SK, PL, PL2 (if you use etlogistik.com)
$testService = true // true if testing only
);
// $G->setEncoding('CP1250'); // UTF-8 is default
// sets default distribution channel (default is Geis::PARCEL)
// $G->setDefaultDistribution(Geis::CARGO);
//--------- ALL FUNCTIONS FROM GEIS DOCUMENTATION ARE IMPLEMENTED
echo '<h1>G-Service API</h1>';
echo '<pre>';
// whether service is running
print_r( $G->IsHealthy() );
// list of allowed services
print_r( $G->WrapList() );
print_r( $G->ServiceList() );
print_r( $G->AddServiceList(10) ); // extras for service CODE=10 (parcel)
// returns next work day, if before 12 a.m. then the same day
echo $G->getNextPossiblePickup(1200);
// orders a pickup
$G->CreatePickup('2019-02-06','732848164', 'mzvarik@gmail.com', $packagesCount = 1);
//-------------------------------
// NEW SHIPMENT
// It will be picked up at your pickup address (usually company address)
$receiver = Geis::getFullAddress(
'Mateusz Bartczak',
'Grzybowska 79',
'Warszawa',
'00-844',
'PL',
'mateusz@company.pl',
'603123456' // +48 will be added automatically
);
// List of packages for this one shipment (usually 1)
// Dimensions are in metres and are required for PL (just for first package)
$packages = array();
$packages[] = array(0.72, 1.2, 0.33, 0.22); // weight_kg | width | height | length
$packages[] = array(0.5); // weight_kg
$ret = $G->InsertExport(
'2019-02-06', // pickup date
$receiver, // package receiver
$packages,
'Go to second floor', // driver note
array(150, 'PLN', '55555'), // COD (cash on delivery) - amount | currency | variable symbol
false, // whether to send confirmation email to receiver
'mypackage_01' // package reference number
);
echo $ret->PackNumber;
// if you have more packages
$additionalPackNumbers = (array) $ret->MergedPackNumbers->string;
//------------
// NEW ORDER - from place A to B (no need to create a pickup)
// for example in case your customer wants to ship something to you
$sender = Geis::getFullAddress(
'Nikol Bartek',
'Dzielna 11',
'Warszawa',
'00-844',
'PL',
'bartek@onet.pl',
'731888999'
);
$ret = $G->InsertOrder( // this function is same as InsertExport, but begins with sender address
$sender, // sender address
'2019-02-06', // pickup date
$receiver, // receiver address
$packages
);
echo $ret->PackNumber;
//------------
# PDF LABELS
$shipmentNumbers = array('35700145379', '35700145380', '35700145381');
// $G->GetLabel($shipmentNumbers, $Position = 1); // returns PDF string
$G->PrintLabel($shipmentNumbers); // pritns PDF with headers
# LIST OF SHIPMENTS
$shipments = $G->ListOfShipments('2019-02-06');
print_r($shipments);
# SHIPMENT DETAIL
$detail = $G->ShipmentDetail('35700145389');
print_r($detail);
# SHIPMENT STATUS
$status = $G->ShipmentStatus('35700145389');
print_r($status);
# CANCEL SHIPMENT
$res = $G->DeleteShipment(array('35700145385', '35700145379'));
print_r($res);
# PICKUP LIST PROTOCOL
// $G->GetPickupList('2019-02-06');
// $G->PrintPickupList('2019-02-06'); // prints PDF with headers
}
catch (Exception $e)
{
echo '<div style="color:#000;padding:10px;margin:10px;font-family:Tahoma;font-size:13px;font-weight:bold">';
echo 'Geis Error ['.$e->getCode().']: '.$e->getMessage();
echo '</div>';
}
Historia zmian
01.01.2019 - Geis v2 (updated functions)
03.05.2018 - Małe zmiany na wyjściu PDF
01.04.2017 - Zmiana z HTTP API na G-Service
17.12.2016 - Opublikowano