PTT Kargo API
PTT Kargo, devlet kuruluşu olarak Türkiye'nin en geniş dağıtım ağına sahiptir. Köy ve kırsal bölgelere bile teslimat yapar. Web servis API'si ile gönderi oluşturma ve takip işlemlerini otomatize edebilirsiniz.
API Bilgileri
- WSDL: https://pttws.ptt.gov.tr/postakargo/PttTrx?wsdl
- Test WSDL: https://pttws-test.ptt.gov.tr/postakargo/PttTrx?wsdl
1. Gönderi Oluşturma
$wsdl = 'https://pttws.ptt.gov.tr/postakargo/PttTrx?wsdl';
$client = new SoapClient($wsdl, [
'trace' => true,
'exceptions' => true,
]);
$params = [
'muspiArg' => [
'username' => 'PTT_USER',
'password' => 'PTT_PASS',
'custCode' => 'MUSTERI_KODU',
'senderName' => 'Eka Sunucu Ltd.',
'senderPhone' => '02121234567',
'receiverName' => 'Ali Yılmaz',
'receiverPhone'=> '05551234567',
'receiverAddr' => 'Cumhuriyet Mah. No:10 Ankara',
'cityCode' => '006',
'townCode' => '001',
'weight' => 2000,
'desi' => 3,
],
];
$result = $client->createShipment($params);
$barcode = $result->barcodeNo;
2. Kargo Takip
$track = $client->queryShipment([
'username' => 'PTT_USER',
'password' => 'PTT_PASS',
'barcode' => $barcode,
]);
foreach ($track->movements as $move) {
echo $move->date . ' - ' . $move->status;
}