Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoeken API error when searching #2

Closed
dataconnectnl opened this issue Apr 17, 2022 · 3 comments
Closed

Zoeken API error when searching #2

dataconnectnl opened this issue Apr 17, 2022 · 3 comments

Comments

@dataconnectnl
Copy link

Fatal error: Uncaught Error: Using $this when not in object context

php 8.1

try {
$resultaten = $this->client->search($query);
foreach ($resultaten->getResultaten() as $searchResult) {
// do something with $searchResult
}
} catch(NotFoundException | ApiException $exception) {
// handle error
}

@DaanGeurts
Copy link
Contributor

If you use this library outside an object you cannot use $this because it's used to access members or functions of that object.
You should use something like the following:

$rootCertificate = <location_of_root_certificate>;
$client = KvkClientFactory::create(<YOUR_API_KEY>, 'test | production', $rootCertificate);

$query = new SearchQuery();
$query->setKvkNumber('KVK nummer to search for');

try {
    $resultaten = $client->search($query);
    foreach ($resultaten->getResultaten() as $searchResult) {
        // do something with $searchResult
    }
} catch(NotFoundException | ApiException $exception) {
    // handle error
}

@DaanGeurts
Copy link
Contributor

Does this solve your problem?

@dataconnectnl
Copy link
Author

yes it's resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants