Knowband Blog | Ecommerce Modules

HubBox Error: Bad Response Code

Problemstellung: In der Antwort der Authentifizierungs-API der HubBox ist ein Fehler aufgetreten. "HubBox-API-Fehler: Ungültiger Antwortcode

Lösung:? If you are facing issue as shown below while you are checking Authentication API, it may be because of Authentication API is verifying SSL certificate for connection.

Zu diesem Zweck können Sie die SSL-Überprüfung in der CURL-Anforderung deaktivieren, indem Sie die folgenden Zeilen hinzufügen.

curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false);

Nehmen Sie in der Funktion refreshToken () unter HubBox / PHP / HubBox / Authentication.php die folgenden Änderungen an der Curl-Anforderung der Authentifizierungs-API vor:

$ ch = curl_init (); $ post_string = http_build_query ($ fields); curl_setopt ($ ch, CURLOPT_URL, $ endpoint); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_POST, 1); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post_string); curl_setopt ($ ch, CURLOPT_HTTPHEADER, Array ('Inhaltstyp: application / x-www-form-urlencoded')); curl_setopt ($ ch, CURLOPT_USERPWD, $ this -> _ magento_user. ":". $ this -> _ magento_key); curl_setopt ($ ch, CURLOPT_VERBOSE, 1); curl_setopt ($ ch, CURLOPT_HEADER, 1); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false); $ output = curl_exec ($ ch); $ header_size = curl_getinfo ($ ch, CURLINFO_HEADER_SIZE); $ httpcode = curl_getinfo ($ ch, CURLINFO_HTTP_CODE); $ body = substr ($ output, $ header_size); curl_close ($ ch);

Wenn dies das Problem war, müssen Sie diese Zeilen in allen APIs von HubBox-APIs zum Erstellen von Paketen, Abbrechen von Paketen, Hinzufügen von Verfolgungs- und Sammelpunkten wie unten beschrieben hinzufügen.

Paket-API erstellen: Nehmen Sie in der Funktion sendOrder () unter HubBox / PHP / HubBox / Parcel.php die folgenden Änderungen an der Curl-Anforderung der Create Parcel API vor:

$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ this-> getOrderUrl ()); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ body); curl_setopt ($ ch, CURLOPT_HTTPHEADER, Array ('Inhaltstyp: application / json', 'Autorisierung: Inhaber'. $ token, 'Inhaltslänge:'. strlen ($ body))); curl_setopt ($ ch, CURLOPT_VERBOSE, 1); curl_setopt ($ ch, CURLOPT_HEADER, 1); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false); $ output = curl_exec ($ ch); $ header_size = curl_getinfo ($ ch, CURLINFO_HEADER_SIZE); $ body = substr ($ output, $ header_size); $ httpCode = curl_getinfo ($ ch, CURLINFO_HTTP_CODE); curl_close ($ ch);

Paket-API abbrechen: Nehmen Sie in der Funktion cancelOrder () unter HubBox / PHP / HubBox / Parcel.php die folgenden Änderungen an der Curl-Anforderung der Cancel Parcel-API vor:

$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ this-> getCancelUrl ($ hubBoxParcelId)); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ postBody); curl_setopt ($ ch, CURLOPT_HTTPHEADER, Array ('Inhaltstyp: application / json', 'Autorisierung: Inhaber'. $ token, 'Inhaltslänge:'. strlen ($ postBody))); curl_setopt ($ ch, CURLOPT_VERBOSE, 1); curl_setopt ($ ch, CURLOPT_HEADER, 1); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false); $ output = curl_exec ($ ch); $ header_size = curl_getinfo ($ ch, CURLINFO_HEADER_SIZE); $ body = substr ($ output, $ header_size); $ httpCode = curl_getinfo ($ ch, CURLINFO_HTTP_CODE); curl_close ($ ch);

Tracking-API hinzufügen: Nehmen Sie in der Funktion addTracking () unter HubBox / PHP / HubBox / Parcel.php die folgenden Änderungen an der Curl-Anforderung der Add Tracking-API vor:

$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ this-> getTrackingUrl ($ hubBoxParcelId)); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ postBody); curl_setopt ($ ch, CURLOPT_HTTPHEADER, Array ('Inhaltstyp: application / json', 'Autorisierung: Inhaber'. $ token, 'Inhaltslänge:'. strlen ($ postBody))); curl_setopt ($ ch, CURLOPT_VERBOSE, 1); curl_setopt ($ ch, CURLOPT_HEADER, 1); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false); $ output = curl_exec ($ ch); $ header_size = curl_getinfo ($ ch, CURLINFO_HEADER_SIZE); $ body = substr ($ output, $ header_size); $ httpCode = curl_getinfo ($ ch, CURLINFO_HTTP_CODE); curl_close ($ ch);

Collectpoint API: Nehmen Sie in der Funktion getCollectPoint () unter HubBox / PHP / HubBox / CollectPoints.php die folgenden Änderungen an der Curl-Anforderung der Collectpoint-API vor:

$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ this-> getCollectPointUrl (). '/'. $ id); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_HTTPHEADER, Array ('Inhaltstyp: application / json')); curl_setopt ($ ch, CURLOPT_VERBOSE, 1); curl_setopt ($ ch, CURLOPT_HEADER, 1); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false); // Wenn wir private Sammelpunkte haben, müssen wir die Anfrage authentifizieren, wenn ($ this -> _ config-> hasPrivateCps ()) {$ header [] = "Authorization: Bearer". $ this -> _ auth-> getAccessToken (); curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header); } $ output = curl_exec ($ ch); $ header_size = curl_getinfo ($ ch, CURLINFO_HEADER_SIZE); $ body = substr ($ output, $ header_size); $ httpCode = curl_getinfo ($ ch, CURLINFO_HTTP_CODE); curl_close ($ ch);

Weitere verwandte Artikel finden Sie hier: HubBox-Fehler: Falsche Produktdaten in der Antwort der Create Parcel API