<?php
$baseUrl = 'http://nominatim.openstreetmap.org/search?format=json&limit=1';
$name = urlencode( 'Mainz, Germany' );
$data = file_get_contents( "{$baseUrl}&q={$name}" );
$json = json_decode( $data );
var_dump( $json[0] );
?>
Output
NULL
<?php
$baseUrl = 'http://nominatim.openstreetmap.org/search?format=json&limit=1';
$name = urlencode( 'Mainz, Germany' );
$data = file_get_contents( "{$baseUrl}&q={$name}" );
$json = json_decode( $data );
var_dump( $json[0] );
?>