Itella PickupPointService

atlaz 14.05.12 13:07

Hakee ja palauttaa itellan noutopisterekisterin.

 Tekstiversio  Arvo: 0 (0 ääntä)  Äänestä: +  -
<?php

// Itellan uusi versio Fetchlocationservicestä (http://mureakuha.com/koodikirjasto/1196)
// Muuttuneet asiat: Palautuva tieto, WDSL-osoitteet ja hakutapa.


// vaatii toimiakseen Itellan PUPServiceExternal.wsdl-tiedoston
// joka löytyy osoitteesta http://verkkokauppiaalle.itella.fi/postin-noutopisteet-verkkokaupan-toimitustavaksi
// HOX! Testatessa käytetään PUPServiceExternalTest.wsdl.
// HOX2!! Itellan dokumentaatiossa olevat wdsl-tiedostot eivät syystä tai toisesta toimi (https://ohjelmat.posti.fi/PickupPointService/SearchExternal). Selvitys postilta miksei.


// PUPServiceExternal.wsdl
$client = new SoapClient("PUPServiceExternal.wsdl", array('login' => "username",'password' => "password")); // Testiversio ei vaadi loginnia (vielä).

// haetaan FindByType 0 joka palauttaa kaikki toimipisteet
// Type of pick up point: 1=Posti, 2=Noutopiste, 3= SmartPOST. 
// Value zero (0) results all types of pick points. 
// Request message must contain one FindByType element.
// hox, findbytype 0 ei käytännössä toimi. Jos haluaa kaikki, pitää hakea erikseen type1, type2, type3 jne.
// countrycode lisätty, koska vissiin Virossaki on tätänykyä smartpost-pisteitä joita voi hyödyntää verkkokaupassaan.

$result = $client->PickUpPointExternal(array('PickUpPointSearchRequest' => array('FindByType' => 0, 'FindByCountryCode' => 'FI', 'contractNumber' => 'SOPIMUSTUNNUS'))); //testatessa sopimustunnus 666444

// yo dawg i heard you like looping so we put an array in your array so you can foreach while you foreach
foreach ($result as $a) {
    foreach ($a as $b) {
        foreach ($b as $c){
        $pubname = $c->PublicName; // Name of the post office of the pick-up point
                $labname = $c->LabelName; // Name of the pick up-point to be printed on the address label (e.g. c/o Posti)
                $address = $c->Address; // Street address of the pick-up
                $postcode = $c->PostCode; // Post code of the pick up point.
                $city = $c->City; // City of the pick-up point in the corresponding language.
                $countrycode = $c->CountryCode; // Country code of the pick-up point (ISO-3166/A2)
                $availability = $c->Availability; // Opening and closing times of the pick-up point in the corresponding language.
                $exavailability = $c->ExceptionalAvailability; //Not typical opening and closing times of the pick-up point in the corresponding language.
                $addinfo = $c->AdditionalInfo; //Additional location information about pick-up point. (e.g. “post office located in the second floor”)
                $pickuptime = $c->PickupTime; // Time when parcels are picked up from the pick-up point.
                $pupcode = $c->PUPCode; // ID of the pick-up point
                $routservcode = $c->RoutingServiceCode; // Service code for the pick-up point. This is important information especially when there is more than one pick-up point in the same postal code area. “Home post office” is tagged for code 3200 and all the others ascending up to 3210.       
                $puptype = $c->PUPType; // Type of the pick-up point in human readable format in the corresponding language. In Finnish values are: Posti, Noutopiste, SmartPOST
                $maplong = $c->MapLongitude; // Pick-up point’s coordinate info
                $maplat = $c->MapLatitude; // Pick-up point’s coordinate info.
                $order = $c->order; // order (ei speksattu, mutta palautuu)
            }
    }
}


/*
Palautuva tieto, ote var_dumppi:

["PickUpPoint"]=>
    array(955) {
      [0]=>
      object(stdClass)#4 (16) {
        ["PublicName"]=>
        string(15) "Posti, Keskusta"
        ["LabelName"]=>
        string(19) "c/o Posti, Keskusta"
        ["Address"]=>
        string(15) "Elielinaukio 2F"
        ["PostCode"]=>
        string(5) "00100"
        ["City"]=>
        string(8) "HELSINKI"
        ["CountryCode"]=>
        string(2) "FI"
        ["Availability"]=>
        string(39) "ma-pe 8.00 - 20.00, la-su 10.00 - 14.00"
        ["ExceptionalAvailability"]=>
        string(129) "16.5. avoinna klo 18 saakka, to 17.5. suljettu / Pikakirjeen viimeinen jättöaika ma-pe klo 19 Poste Restante avoinna ma-pe 9-18"
        ["AdditionalInfo"]=>
        string(0) ""
        ["PickupTime"]=>
        string(5) "17.00"
        ["PUPCode"]=>
        string(9) "001003200"
        ["RoutingServiceCode"]=>
        string(4) "3200"
        ["PUPType"]=>
        string(5) "Posti"
        ["MapLongitude"]=>
        string(10) "24,9393627"
        ["MapLatitude"]=>
        string(10) "60,1723247"
        ["order"]=>
        int(1)
      }

*/

?>




Koska en osaa ja oon muutenkin vähän hölmö ja laiska, niin tässä ei oo mitään virhechekkauksia tai muuta. Lähinnä lisäsin tämän tänne, että jos joku muu painii samaisen ongelman kanssa, niin google palauttaisi edes yhden jutun hakusanalla PUPServiceExternal.
Tätä saa/pitää mielellään parantaa enkä suosittele kenenkään ottavan tätä tällaisenaan käyttöön.