1. Go to this page and download the library: Download tcgunel/omniship-surat library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tcgunel / omniship-surat example snippets
use Omniship\Omniship;
$carrier = Omniship::create('Surat');
$carrier->initialize([
'kullaniciAdi' => '1038106246', // 10-digit Cari Kodu
'sifre' => '123456', // Cari Sifre (for shipment creation & cancel)
'cariKodu' => '1038106246', // Same Cari Kodu (for tracking)
'webSifre' => '123456.Ff', // Web Servis Sifresi (for tracking queries)
'testMode' => true,
]);
use Omniship\Common\Address;
use Omniship\Common\Package;
use Omniship\Common\Enum\PaymentType;
$response = $carrier->createShipment([
'shipTo' => new Address(
name: 'Mehmet Demir',
street1: 'Ataturk Cad. No:42',
city: 'Ankara',
district: 'Cankaya',
phone: '05559876543',
email: '[email protected]',
),
'packages' => [
new Package(weight: 2.5, desi: 3),
],
'trackingNumber' => 'SIPARIS-001', // OzelKargoTakipNo (your custom tracking code)
'referenceNumber' => 'REF-001', // Optional: group shipments
'paymentType' => PaymentType::SENDER, // SENDER (1=Pesin) or RECEIVER (2=Ucret Alici)
'cargoType' => 3, // 1=Dosya, 2=Mi, 3=Koli
'cargoContent' => 'Elektronik urun', // Optional
])->send();
if ($response->isSuccessful()) {
echo $response->getBarcode(); // 14-digit barcode from Surat
echo $response->getTrackingNumber(); // OzelKargoTakipNo you provided
} else {
echo $response->getMessage(); // Error description
}