-
Notifications
You must be signed in to change notification settings - Fork 49
Unknown error | International-Shippings #5
Comments
Please remove the Correct is: // Using my constances:
$shipmentDetails->setProduct(DHL_ShipmentDetails::PRODUCT_TYPE_NATIONAL_PACKAGE);
// OR (If you dont want to use the constances, just the String of your product):
$shipmentDetails->setProduct('V01PAK'); And for the second one: // Using constances:
$shipmentDetails->setProduct(DHL_ShipmentDetails::PRODUCT_TYPE_INTERNATIONAL_PACKAGE);
// OR as String:
$shipmentDetails->setProduct('V53WPAK'); Please consider using an IDE, it will help you a lot =) (EG: Showing you constances etc)But I never test it with international packages, please tell me if it works after you fixed the typo =) May my description in the readme is a little unclear? |
thx.... Fatal error: Call to a member function setProduct() on null in /XXX/v2_neues_sdk.php on line 28 #if($utf_landcode == 'DE'){
$credentials->setEpk('xxxxxxxx0102');
$shipmentDetails->setProduct('V01PAK');
#} else {
#$credentials->setEpk('xxxxxxxxxx5302');
#$shipmentDetails->setProduct('V53WPAK');
#} kann ich auch auf Deutsch antworten? |
Ja klar, wenns nicht anders geht^^ Hast du den die ganze Datei (Ohne Zugangsdaten) zb auf Pastebin, damit ich mal sehen kann? |
ich hab die if Abfrage nun raus gemacht. Hier mal das Script. #error_reporting(-1);
ini_set('display_errors', TRUE);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require_once('includes' . DIRECTORY_SEPARATOR . 'DHL_BusinessShipment.php');
$heute = date("Y-m-d");
$utf_name = $name[$key];
$utf_namezusatz = $namezusatz[$key];
$utf_kontakt = $kontakt[$key];
$utf_strasse = $strasse[$key];
$utf_hausnummer = $hausnummer[$key];
$utf_landcode = $landcode[$key];
$utf_plz = $plz[$key];
$utf_ort = $ort[$key];
$utf_email = $email[$key];
$lap_gewicht = $p_gewicht[$key];
$testModus = false;
$version = '2.2';
$credentials = new DHL_Credentials();
$credentials->setUser('xxxxx'); // DHL-Account (Same as if you Login with then to create Manual-Labels)
$credentials->setSignature('xxxxxx'); // DHL-Account-Password
#if($utf_landcode == 'DE'){
$credentials->setEpk('xxxxx');
$shipmentDetails->setProduct('V01PAK');
#} else {
#$credentials->setEpk('xxxxxx');
#$shipmentDetails->setProduct('V53WPAK');
#}
$credentials->setApiUser('DHLAPPID'); // Your Applications-ID (You can find it in your DHL-Dev-Account)
$credentials->setApiPassword('TOKEN'); // Your Applications-Token (You can find it also where you found the App-Id)
$shipmentDetails->setShipmentDate($heute);
$shipmentDetails->setWeight($lap_gewicht);
$sender = new DHL_Sender();
$sender->setName('Firma');
$sender->setStreetName('Strasse');
$sender->setStreetNumber('10');
$sender->setZip('90489');
$sender->setCity('Nürnberg');
$sender->setCountry('Germany');
$sender->setCountryISOCode('DE');
$sender->setAddressAddition('1 OG');
$sender->setName2('Firma');
$sender->setPhone('0911123456789');
$sender->setEmail('info@mail.de');
$receiver = new DHL_Receiver();
$receiver->setName($utf_name);
$receiver->setStreetName($utf_strasse);
$receiver->setStreetNumber($utf_hausnummer);
$receiver->setZip($utf_plz);
$receiver->setCity($utf_ort);
$receiver->setCountryISOCode($utf_landcode);
$receiver->setName2($utf_namezusatz);
$receiver->setEmail($utf_email);
$receiver->setContactPerson($utf_kontakt);
$service = new DHL_Service();
$dhl = new DHL_BusinessShipment($credentials);
$dhl->setSender($sender);
$dhl->setReceiver($receiver);
$dhl->setService($service);
$dhl->setShipmentDetails($shipmentDetails);
$dhl->setReceiverEmail($utf_email); // Needed if you want inform the receiver via mail
$dhl->setLabelResponseType('URL');
$response = $dhl->createShipment();
if($response !== false)
var_dump($response);
else
var_dump($dhl->getErrors());
var_dump($dhl->getLastXML()); |
Naja du greifst auf Du musst das Shipment-Detail objekt erstellen^^ (Der Schritt hier) $shipmentDetails = new DHL_ShipmentDetails($credentials->getEpk(10) . '0101'); Musst die Endung eben noch anpassen, da du ja nicht 0101 nutzt, sondern 0102 bzw 0103^^ |
Danke.... und Respekt für die schnellen Antworten. Sorry, bin net der crack in php. |
Kein Problem und viel Erfolg weiterhin^^ Sag bescheid, ob das mit dem Internationalen Versand funktioniert, so lange lass ich das mal offen ;) |
Getestet und läuft.
Etikette wird trotzdem erstellt, kostet halt 0,35€ pro Etikette. Mein Script sieht so aus. require_once('includes' . DIRECTORY_SEPARATOR . 'DHL_BusinessShipment.php');
$heute = date("Y-m-d");
$utf_name = utf8_encode($name[$key]);
$utf_namezusatz = utf8_encode($namezusatz[$key]);
$utf_kontakt = utf8_encode($kontakt[$key]);
$utf_strasse = utf8_encode($strasse[$key]);
$utf_hausnummer = utf8_encode($hausnummer[$key]);
$utf_landcode = utf8_encode($landcode[$key]);
$utf_plz = utf8_encode($plz[$key]);
$utf_ort = utf8_encode($ort[$key]);
$utf_email = utf8_encode($email[$key]);
$lap_gewicht = utf8_encode($p_gewicht[$key]);
$testModus = false;
$version = '2.2';
$credentials = new DHL_Credentials();
$credentials->setUser('USER_XXXXXXXXXX'); // DHL-Account (Same as if you Login with then to create Manual-Labels)
$credentials->setSignature('PW_XXXXXXXXXXXX'); // DHL-Account-Password
if($utf_landcode == 'DE'){
$credentials->setEpk('XXXXXXXXX_0102');
$shipmentDetails = new DHL_ShipmentDetails($credentials->getEpk(10) . '0102');
$shipmentDetails->setProduct('V01PAK');
} else {
$credentials->setEpk('XXXXXXXXXXX_5302');
$shipmentDetails = new DHL_ShipmentDetails($credentials->getEpk(10) . '5302');
$shipmentDetails->setProduct('V53WPAK');
}
$credentials->setApiUser('PHPAPPID'); // Your Applications-ID (You can find it in your DHL-Dev-Account)
$credentials->setApiPassword('TOKEN'); // Your Applications-Token (You can find it also where you found the App-Id)
$shipmentDetails->setShipmentDate($heute);
$shipmentDetails->setWeight($lap_gewicht);
$sender = new DHL_Sender();
$sender->setName('Absender');
$sender->setStreetName('Absender Str');
$sender->setStreetNumber('Absender HNr.');
$sender->setZip('Absender PLZ');
$sender->setCity('Absender Stadt');
$sender->setCountry('Germany');
$sender->setCountryISOCode('DE');
$sender->setAddressAddition('Zb. 1 OG');
$sender->setName2('Absender Name2');
$sender->setPhone('Rufnummer');
$sender->setEmail('Absender');
$receiver = new DHL_Receiver();
$receiver->setName($utf_name);
$receiver->setStreetName($utf_strasse);
$receiver->setStreetNumber($utf_hausnummer);
$receiver->setZip($utf_plz);
$receiver->setCity($utf_ort);
$receiver->setCountryISOCode($utf_landcode);
$receiver->setName2($utf_namezusatz);
$receiver->setEmail($utf_email);
$receiver->setContactPerson($utf_kontakt);
$service = new DHL_Service();
$dhl = new DHL_BusinessShipment($credentials);
$dhl->setSender($sender);
$dhl->setReceiver($receiver);
$dhl->setService($service);
$dhl->setShipmentDetails($shipmentDetails);
$dhl->setReceiverEmail($utf_email); // Needed if you want inform the receiver via mail
$dhl->setLabelResponseType('URL');
$response = $dhl->createShipment();
if($response !== false)
var_dump($response);
else
var_dump($dhl->getErrors());
var_dump($dhl->getLastXML());
$sendungsnummer = $response->getShipmentNumber();
$label_url = $response->getLabel(); // Returns the Label URL or Base64-Label-String or null
$label_url2 = $response->getReturnLabel(); // Returns the ReturnLabel (URL/B64) or null
$sepnr = $response->getSequenceNumber(); // Returns your provided sequence number or null
$status_code = $response->getStatusCode(); // Returns the Status-Code (Difference to DHL - Weak-Validation is 1 not 0)
$status_text = $response->getStatusText(); // Returns the Status-Text or null
$status_message = $response->getStatusMessage(); // Returns the Status-Message (More details) or null
echo "<br>
$sendungsnummer <br>
$label_url <br>
$label_url2 <br>
$sepnr <br>
$status_code <br>
$status_text <br>
$status_message <br>
";
// Speichert das Lappel im Ordner label.
file_put_contents("./label/$sendungsnummer.pdf", file_get_contents($label_url)); |
Super, es läuft =)! Danke dir fürs testen. Soweit ich weiß, muss man selbst fehlerhafte Etiketten stornieren. Das kannst du mit der Funktion hier tun: (Findest du in der /**
* Deletes a Shipment
*
* @param string $shipmentNumber - Shipment-Number of the Shipment to delete
* @return bool|DHL_Response - Response
*/
public function deleteShipment($shipmentNumber) { /* (...) */ } Du könntest das selbstverständlich auch automatisieren, indem du bei einem Weak-Validation-Error einfach automatisch diese funktion mit der Sende-Nummer aufrufst. zb: if($response !== false) {
if($response->getStatusCode() === DHL_Response::DHL_ERROR_WEAK_WARNING)
$dhl->deleteShipment($response->getShipmentNumber());
} Allerdings sind da die Lösungen bei dir, da ich schlecht prüfen kann ob es die Adresse gibt/mit der PLZ übereinstimmt^^ Da kannste ja dich einfach auf die Response verlassen. Nun gut, super das alles soweit geht, ich schließe das hier mal. Danke fürs testen =) |
hello,
we test your php sdk and have on problem.
We look if a national or international shipping.
If de = national V01PAK and epk is .....0102
else = international V53WPAK and epk is .....0302
is not working.
The text was updated successfully, but these errors were encountered: