DivideBV / Postnl

Library to connect to PostNL's SOAP service called CIF
GNU General Public License v2.0
31 stars 40 forks source link

GetLocation Function #47

Closed PaulVanDeKamer closed 7 years ago

PaulVanDeKamer commented 7 years ago

Hi, Hope someone can help me out. Trying to get the Locations for drop points. this is my code:

include ("./vendor/autoload.php");
use DivideBV\Postnl\Postnl;
use DivideBV\Postnl\ComplexTypes;
$client = new Postnl(
    Customer number,   // Customer number
    'CCODE',     // Customer code
    'Customer name',  // Customer name
    'Username',     // Username
    'Password', // Password
    Collection location,     // Collection location
    'Globalpack',   // Globalpack
    false        // Whether to use PostNL's sandbox environment.
);
$test = $client->getLocation('1211GG');

Will result in this error:

PHP Fatal error:  Uncaught exception 'DivideBV\\Postnl\\ComplexTypes\\CifException' in vendor/dividebv/postnl/src/Postnl.php:577
Stack trace:
#0 vendor/dividebv/postnl/src/Postnl.php(503): DivideBV\\Postnl\\Postnl->call('LocationClient', 'getLocation', Object(DivideBV\\Postnl\\ComplexTypes\\GetLocationRequest))
#1 postnl-test.php(22): DivideBV\\Postnl\\Postnl->getLocation('1211GG')
#2 {main} thrown in vendor/dividebv/postnl/src/Postnl.php on line 577

Hope someone can help me out.

slokhorst commented 7 years ago

Catch the exception and see what's the problem:

try {
    $test = $client->getLocation('1211GG');
} catch (Exception $e) {
    var_dump($e);
}
PaulVanDeKamer commented 7 years ago

This explains a lot. The user is not authorized for the method 'GetLocation'. Thanks.