-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
84 lines (70 loc) · 2.61 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require __DIR__ . '/GLS/API.php';
ini_set('memory_limit','1024M');
ini_set('max_execution_time', 600);
try {
// Create instance
$api = new GLS\API([
'username' => 'myglsapitest@test.mygls.hu',
'password' => '1pImY_gls.hu',
'client_number' => '100000001',
'country_code' => 'HU-TEST',
'label_paper_size' => 'A4_2x2'
]);
// Create parcel
$parcels = [];
$parcel = new StdClass();
$parcel->ClientNumber = $api->client_number;
$parcel->ClientReference = "TEST PARCEL";
$parcel->CODAmount = 0;
$parcel->CODReference = "COD REFERENCE";
$parcel->Content = "CONTENT";
$parcel->Count = 1;
$deliveryAddress = new StdClass();
$deliveryAddress->ContactEmail = "something@anything.hu";
$deliveryAddress->ContactName = "Contact Name";
$deliveryAddress->ContactPhone = "+36701234567";
$deliveryAddress->Name = "Delivery Address";
$deliveryAddress->Street = "Európa u.";
$deliveryAddress->HouseNumber = "2";
$deliveryAddress->City = "Alsónémedi";
$deliveryAddress->ZipCode = "2351";
$deliveryAddress->CountryIsoCode = "HU";
$deliveryAddress->HouseNumberInfo = "/b";
$parcel->DeliveryAddress = $deliveryAddress;
$pickupAddress = new StdClass();
$pickupAddress->ContactName = "Contact Name";
$pickupAddress->ContactPhone = "+36701234567";
$pickupAddress->ContactEmail = "something@anything.hu";
$pickupAddress->Name = "Pickup Address";
$pickupAddress->Street = "Európa u.";
$pickupAddress->HouseNumber = "2";
$pickupAddress->City = "Alsónémedi";
$pickupAddress->ZipCode = "2351";
$pickupAddress->CountryIsoCode = "HU";
$pickupAddress->HouseNumberInfo = "/a";
$parcel->PickupAddress = $pickupAddress;
$parcel->PickupDate = null;
$service1 = new StdClass();
$service1->Code = "PSD";
$parameter1 = new StdClass();
$parameter1->StringValue = "2351-CSOMAGPONT";
$service1->PSDParameter = $parameter1;
$services = [];
$services[] = $service1;
$parcel->ServiceList = $services;
$parcels[] = $parcel;
// First method is PrintLabels, which simply crate a label
$first_method = $api->PrintLabels($parcels);
print_r($first_method);
// Second method is GetPrintedLabels
$second_method_prepare = $api->PrepareLabels($parcels);
print_r($second_method_prepare);
$second_method_labels = $api->GetPrintedLabels(array($second_method_prepare->PrepareLabelsResult->ParcelInfoList->ParcelInfo->ParcelId));
print_r($second_method_labels);
// Third method is GetPrintData, for custom labels
$third_method = $api->GetPrintData($parcels);
print_r($third_method);
}catch (Exception $e){
print_r($e);
}