Ora che mi ci fai pensare stavo caricando la pagina dal mio pc mentre la pagina è hostata in un server remoto. Potrebbe essere qualche configurazione del server?
Codice PHP:
<?php
// recupero la query, elimino gli spazi bianche e faccio l'urlencode
$q = $_GET['q'];
$feedURL = "http://gdata.youtube.com/feeds/api/videos?vq={$q}";
$sxml = simplexml_load_file($feedURL);
echo "<table border='0'>";
foreach ($sxml->entry as $entry) {
$media = $entry->children('http://search.yahoo.com/mrss/');
$attrs = $media->group->player->attributes();
$watch = $attrs['url'];
$attrs = $media->group->thumbnail[1]->attributes();
$thumbnail = substr($attrs['url'], 0,-5)."default.jpg";
// durata <yt:duration>
$yt = $media->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->duration->attributes();
$length = $attrs['seconds'];
// numero di visualizzazioni <yt:stats>
$yt = $entry->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->statistics->attributes();
$viewCount = $attrs['viewCount'];
// rating <gd:rating>
$gd = $entry->children('http://schemas.google.com/g/2005');
if ($gd->rating) {
$attrs = $gd->rating->attributes();
$rating = round($attrs['average'],2);
}else{
$rating = 0;
}
echo "<tr>
<td>
</td>
<td>
<center>
<a href=\"{$watch}\">{$media->group->title}</a>
" . sprintf("%0.2f", $length/60) . " min. | {$viewCount} views
</center>
</tr>
<tr>
<td class=\"tdimg\">
<a href=\"{$watch}\">
<img src=\"{$thumbnail}\"/>
</a>
</td>
<td>
<div id='descrizione_video'>
{$media->group->description}
</div>
</td>
</tr></br></br>";
}
echo "</table>";
?>