3v4l.org

run code in 300+ PHP versions simultaneously
<?php $privateKey = '0ac56cf42961b3a00e3a54e8608ac56628331a1a21e28e44288b713442c05d9c'; //your private-key $publicKey = 'd7830ae49fbe30ce79aa033662057fcb8c0d57959411066208444d709c3cd87a'; //your public-key $resource = '/shipment/'; //uri of a resource $timestamp = time(); //only needed for the testing-server $baseUrl = 'https://testing.swissconnect.ch/api/'; $basicAuthUser = 'swissconnect'; $basicAuthPass = 't3St-M4th1lda'; $contentData = '<?xml version="1.0" encoding="UTF-8"?> <ns0:MT_SWISSCONNECT_REQUEST xmlns:ns0="http://postlogistics.schindler.com"><auftrag><system_fk_id>9999</system_fk_id><startdatum>2014-10-24 14:40:44</startdatum><rechnungsbeschreibung_offiziell>4700946399 / S-GE</rechnungsbeschreibung_offiziell><rechnungssteller>2</rechnungssteller><bezahl_kurier_id>600</bezahl_kurier_id><bemerkung>bitte Monteur 30 Min. vorher anrufen / Appelez le monteur 30 Min. avant svp.</bemerkung><auftrag_absender_kontaktadressen><item><firma>Schindler AufzÃ1Ž4ge AG</firma><addresse>Zugerstrasse 13</addresse><postleitzahl>6030</postleitzahl><ort>Ebikon</ort></item></auftrag_absender_kontaktadressen><auftrag_empfaenger_kontaktadressen><item><firma>Schindler AufzÃ1Ž4ge AG</firma><addresse>Friedgrabenstrasse 15</addresse><postleitzahl>8907</postleitzahl><ort>Wettswil</ort><kontakt>Kapinos Tobias / 044 172 8484 844</kontakt></item></auftrag_empfaenger_kontaktadressen><auftrag_dritte_kontaktadressen><item><kontaktadresse_id>62300</kontaktadresse_id><bezahlt_bool>true</bezahlt_bool></item></auftrag_dritte_kontaktadressen><colis><item><anzahl>1</anzahl><gewicht>0.035 </gewicht><laenge>20.000 </laenge><breite>20.000 </breite><hoehe>20.000 </hoehe><beschreibung>Paket</beschreibung></item></colis><auftrag_kuriere_dritte><item><kurier_id>101</kurier_id></item></auftrag_kuriere_dritte></auftrag></ns0:MT_SWISSCONNECT_REQUEST>'; //For the hash-key we do not need the serverPW $url = $baseUrl . $privateKey . '/' . $timestamp . $resource; //generating hash which has to be placed in the header of the request. Header name: X-hash $resultHash = hash('sha256', $url . $contentData); $sendUrl = $baseUrl . $publicKey . '/' . $timestamp . $resource; $httpHeaders = array( "Content-Type: application/xml", "Accept: application/xml", "X-hash: " . $resultHash, "X-language: de", "Authorization: Basic ". base64_encode($basicAuthUser. ':'. $basicAuthPass), ); $httpheaderstring = implode(",", $httpHeaders); echo '$HTTP_HEADER..: '.$httpheaderstring."\n"; echo '$TIMESTAMP....: '.$timestamp."\n"; echo '$SEND_URL.....: '.$sendUrl."\n"; echo '$RESULTHASH...: '.$resultHash."\n"; echo '$URL_FOR_HASH.: '.$url."\n"; echo '$CONTENTDATA..: '.$contentData."\n";

preferences:
32.77 ms | 402 KiB | 5 Q