Thomas Kujawa
Thomas Kujawa

Reputation: 31

403 Forbidden: Access blocked bei guzzlehttp GET nominatim.openstreetmap.org

I get the following error:

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: GET https://nominatim.openstreetmap.org/search?format=json&street=Kantatenweg+25&city=Leipzig&postalcode=04229&country=Germany&addressdetails=1 resulted in a 403 Forbidden response:

 <html> <head> <title>Access blocked</title> </head> <body> <h1>Access blocked</h1> <p>You have been blocked because you have violated the usage policy of OSM's Nominatim geocoding service. Please be aware that OSM's resources are limited and shared between many users. The usage policy is there to ensure that the service remains usable for everybody.

...

This is what my source text looks like. I am grateful for any advice.

<?php

use maxh\Nominatim\Nominatim;
use GuzzleHttp\Client;
   
    $adresse        = [
        'strasse'   =>  $strasseXml,
        'ort'       =>  $datensatz['Ort'],
        'plz'       =>  $datensatz['PLZ']        
    ];

    $url = "http://nominatim.openstreetmap.org/";

    $defaultHeader = [
        'verify' => false,
        'headers', array('User-Agent' => 'api_client')
    ];

    $client = new Client([
        'base_uri'           => $url,
        'timeout'            => 30,
        'connection_timeout' => 5,
    ]);

    $nominatim      = new Nominatim($url);

        $search         = $nominatim->newSearch()
                        ->street($adresse['strasse'])
                        ->city($adresse['ort'])
                        ->postalCode($adresse['plz'])
                        ->country('Germany')
                        ->addressDetails();
        try {
            $ergebnis = $nominatim->find($search);
        } catch (\GuzzleHttp\Exception\ClientException $e) {
        echo "Fehlermeldung: " . $e->getMessage() . "\n";
        echo "HTTP-Code: " . $e->getResponse()->getStatusCode() . "\n";
        echo "Antwort: " . $e->getResponse()->getBody()->getContents() . "\n";
        }

I am submitting the address Kantatenweg+25, Leipzig, 04229, Germany + addressdetails=1 and would like to receive the coordinates.

After displaying the complete error code, I know what to do.

Many thanks to @c3roe!

Upvotes: 0

Views: 21

Answers (0)

Related Questions