<?php
$app = $_GET['app'];
$dom = new DOMDocument();
try{
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: es\r\n" .
"User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n"
)
);
$context = stream_context_create($opts);
$html = file_get_contents('https://play.google.com/store/apps/details?id=' . $app,false,$context);
@$dom->loadHTML($html);
}catch(Exception $e){
echo 'Error: ' . $e->getMessage();
header('HTTP/1.0 404 Not Found');
}
$a = $dom->getElementsByTagName('div');
$nodes = array();
for ($i = 0; $i < $a->length; $i++) {
$attr = $a->item($i)->getAttribute('itemprop');
$nodes[$attr] = $a->item($i)->textContent;
}
if(count($nodes) == 0){
header('HTTP/1.0 404 Not Found');
}
?>
<ul>
<li><b>Nombre:</b> <?php echo $nodes['name']; ?></li>
<li><b>Actualizado:</b> <?php echo $nodes['datePublished']; ?></li>
<li><b>Versión de software:</b> <?php echo $nodes['softwareVersion']; ?></li>
<li><b>Requiere android:</b> <?php echo $nodes['operatingSystems']; ?></li>
</ul>