Fehlermeldung bei URL Abruf

Irgendwelche Probleme mit XAMPP für Windows? Dann ist hier genau der richtige Ort um nachzufragen.

Fehlermeldung bei URL Abruf

Postby Cornsnake30 » 13. July 2023 09:48

Hallo XAMPP Freunde,

ich habe ein Problem, wozu ich im Internet schon so einiges ausprobiert habe.

ich möchte gerne folgende URL mit json Auflösung weiter verarbeiten.
https://nominatim.openstreetmap.org/search?q=Allee+27,+33161&format=json

Wenn ich diese direkt in dem Browser eingebe, bekomme ich dies angezeigt:
[{"place_id":20893868,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":2385679314,"boundingbox":["51.8208689","51.8209689","8.6599639","8.6600639"],"lat":"51.8209189","lon":"8.6600139","display_name":"Volksbank Paderborn-Höxter-Detmold, 27, Allee, Bentlake, Hövelhof, Kreis Paderborn, Nordrhein-Westfalen, 33161, Deutschland","class":"amenity","type":"bank","importance":0.33001,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/money_bank2.p.20.png"},{"place_id":39809230,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":3196325983,"boundingbox":["51.8209228","51.8210228","8.6601059","8.6602059"],"lat":"51.8209728","lon":"8.6601559","display_name":"Ems Apotheke, 27, Allee, Bentlake, Hövelhof, Kreis Paderborn, Nordrhein-Westfalen, 33161, Deutschland","class":"amenity","type":"pharmacy","importance":0.33001,"icon":"https://nominatim.openstreetmap.org/ui/mapicons/health_pharmacy_dispensing.p.20.png"},{"place_id":165302920,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":230041927,"boundingbox":["51.8206928","51.8210457","8.6598938","8.6604023"],"lat":"51.8208585","lon":"8.660144455651434","display_name":"27, Allee, Bentlake, Hövelhof, Kreis Paderborn, Nordrhein-Westfalen, 33161, Deutschland","class":"building","type":"apartments","importance":0.33001},{"place_id":237704064,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":639027297,"boundingbox":["42.6755439","42.6761732","3.0297823","3.0298696"],"lat":"42.6760171","lon":"3.029841","display_name":"Allée 27, Plage Sud, Canet-en-Roussillon, Perpignan, Ostpyrenäen, Okzitanien, Metropolitanes Frankreich, 66140, Frankreich","class":"highway","type":"unclassified","importance":0.20000999999999994},{"place_id":351557442,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":204534900,"boundingbox":["45.7820389","45.782257","4.8175239","4.8183853"],"lat":"45.7820898","lon":"4.8178882","display_name":"Allée 27, Serin, 4th Arrondissement, Lyon, Métropole de Lyon, Rhône, Auvergne-Rhone-Alpen, Metropolitanes Frankreich, 69004, Frankreich","class":"highway","type":"service","importance":0.17500999999999992},{"place_id":144180598,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":154460092,"boundingbox":["45.7616239","45.76245","4.8113243","4.8124253"],"lat":"45.76245","lon":"4.8117087","display_name":"Allée 27, Saint-Just, 5th Arrondissement, Lyon, Métropole de Lyon, Rhône, Auvergne-Rhone-Alpen, Metropolitanes Frankreich, 69005, Frankreich","class":"highway","type":"service","importance":0.17500999999999992},{"place_id":167220901,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":238479660,"boundingbox":["45.7416485","45.7425686","4.8553616","4.8554778"],"lat":"45.7421927","lon":"4.8554036","display_name":"Allée 27, Jean-Macé, 7th Arrondissement, Lyon, Métropole de Lyon, Rhône, Auvergne-Rhone-Alpen, Metropolitanes Frankreich, 69007, Frankreich","class":"highway","type":"service","importance":0.17500999999999992},{"place_id":189675617,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":337342435,"boundingbox":["45.7361601","45.7364151","4.8557921","4.8571179"],"lat":"45.7362024","lon":"4.8565006","display_name":"Allée 27, Audibert-Lavirotte, 8th Arrondissement, Lyon, Métropole de Lyon, Rhône, Auvergne-Rhone-Alpen, Metropolitanes Frankreich, 69008, Frankreich","class":"highway","type":"service","importance":0.17500999999999992},{"place_id":139106667,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":132343824,"boundingbox":["43.9209228","43.9210978","4.8659208","4.8665573"],"lat":"43.9209764","lon":"4.8664505","display_name":"Allée 27, Mistral 7 - Avignon Sud, Avignon, Vaucluse, Provence-Alpes-Côte d'Azur, Metropolitanes Frankreich, 84000, Frankreich","class":"highway","type":"service","importance":0.17500999999999992},{"place_id":359112573,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"way","osm_id":1145297706,"boundingbox":["45.7591404","45.7593068","4.9112035","4.9120094"],"lat":"45.7592237","lon":"4.9116068","display_name":"Allée 27, Les Brosses, Villeurbanne, Lyon, Métropole de Lyon, Rhône, Auvergne-Rhone-Alpen, Metropolitanes Frankreich, 69100, Frankreich","class":"highway","type":"service","importance":0.17500999999999992}]



Bei diesem Code:
Code: Select all
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);


Bekomme ich aber diese Meldung zurück: 301 Moved Permanently

Wenn ich es darüber versuche:
Code: Select all
$json = file_get_contents($address);
    $json = json_decode($json);


Bekomme ich dies zurück: Failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in

Leider weiß ich nun nicht weiter, kann mir einer sagen wo ich da einen Denkfehler habe??

Gruß
René
Cornsnake30
 
Posts: 10
Joined: 30. January 2023 11:46
XAMPP version: 8.1.12
Operating System: Windows 10

Re: Fehlermeldung bei URL Abruf

Postby Cornsnake30 » 13. July 2023 13:07

Also mit diesem Zusatz konnte ich schon mal die Meldung kürzen:

Code: Select all
$context = stream_context_create(array(
        'http' => array(
            'header' => array($_SERVER['HTTP_USER_AGENT'] . "\n\n"),
        ),
    ));



Code: Select all
$context = stream_context_create(array(
        'http' => array(
            'header' => array($_SERVER['HTTP_USER_AGENT'] . "\n\n"),
        ),
    ));
$json = file_get_contents($address, TRUE, $context);
    $json = json_decode($json);


Nun kommt nur noch diese Meldung: Failed to open stream: HTTP request failed!

Diese fällt dadurch dann schon mal weg: HTTP/1.1 403 Forbidden in
Cornsnake30
 
Posts: 10
Joined: 30. January 2023 11:46
XAMPP version: 8.1.12
Operating System: Windows 10


Return to XAMPP für Windows

Who is online

Users browsing this forum: No registered users and 67 guests