Moin
1und1 hat nun URL-fopen-wrapper deaktiviert.
Mit Hilfe einer kleinen Funktion muss das entfernte Dokument halt selbst geholt werden.
folgender Code:
Statt:
$xml = simplexml_load_file("http://ws.geonames.org/findNearbyPostalCodes?postalcode=".$_POST['plz']."&country=".$_SESSION['lang']."&radius=100&maxRows=500&style=SHORT");
Nun:
function get_document($url)
{
$content = '';
$is_header = TRUE;
$base_url = parse_url($url);
if ($fp = @fsockopen($base_url['host'], 80, $errno, $errstr, 5))
{
if (!empty($base_url['query']))
{
$query = '?'.$base_url['query'];
}
else
{
$query = '';
}
$data = 'GET '.$base_url['path'].$query." HTTP/1.0\r\n".
'Host: '.$base_url['host']."\r\n".
"Connection: Close\r\n\r\n";
stream_set_timeout($fp, 5);
fputs($fp, $data);
while(!feof($fp))
{
$line = fgets($fp, 4096);
if (!$is_header)
{
$content .= $line;
}
else
{
if (strlen(trim($line)) == 0)
{
$is_header = FALSE;
}
}
}
fclose($fp);
return $content;
}
else
{
return FALSE;
}
}
if ($data = get_document("http://ws.geonames.org/findNearbyPostalCodes?postalcode=".$_POST['plz']."&country=".$_SESSION['lang']."&radius=100&maxRows=500&style=SHORT") ){
$xml = simplexml_load_string($data);
$xml = new simpleXMLElement($xml->asXML());
}
Gruß Bobby
-> Für jedes Problem gibt es eine Lösung, die einfach, sauber und falsch ist! <-
-> Nicht das Problem macht die Schwierigkeiten, sondern unsere Sichtweise! <-
ie:{ br:> fl:{ va:} ls:< fo:) rl:( n4:( de:> ss:) ch:? js:( mo:} sh:) zu:)