Example #1
0
<?php

header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>\n<rss version='2.0'\n    xmlns:w='http://tempuri.org'\n\txmlns:wfw='http://wellformedweb.org/CommentAPI/'\n\txmlns:dc='http://purl.org/dc/elements/1.1/'\n\txmlns:atom='http://www.w3.org/2005/Atom'\n\txmlns:sy='http://purl.org/rss/1.0/modules/syndication/'\n\txmlns:slash='http://purl.org/rss/1.0/modules/slash/'>\n<channel>\n<title>NASA PHOTOS</title>\n<link>https://marspictures.herokuapp.com/</link>\n<description>Nasa Photos</description>\n<atom:link href='https://marspictures.herokuapp.com/feed.php' rel='self' type='application/rss+xml' />\n<language>en-us</language>";
require 'rover.php';
$Mars = new HelloMars();
$today = strtotime(date("Y-m-d"));
$DateToSearch = date("Y-m-d", mt_rand(1080777600, $today));
$RoverPick = mt_rand(0, 2);
$RoverArray = array_keys($Mars->rovers);
$images = json_decode($Mars->getPictures($DateToSearch, $RoverArray[$RoverPick]));
if (isset($images) && !isset($images->photos)) {
    exit;
    //Just to avoid reach the API limit
} else {
    $rssfeed = '';
    foreach ($images as $image) {
        for ($i = 0; $i < count($image); $i++) {
            $rssfeed .= '<item>';
            $rssfeed .= '<title>' . $image[$i]->id . '</title>';
            $rssfeed .= '<guid>' . $image[$i]->img_src . '</guid>';
            $rssfeed .= '<w:id>' . $image[$i]->id . '</w:id>';
            $rssfeed .= '<w:sol>' . $image[$i]->sol . '</w:sol>';
            $rssfeed .= '<w:camera_name>' . $image[$i]->camera->name . '</w:camera_name>';
            $rssfeed .= '<w:img_src>' . $image[$i]->img_src . '</w:img_src>';
            $rssfeed .= '<w:earth_date>' . date("d/m/Y", strtotime($image[$i]->earth_date)) . '</w:earth_date>';
            $rssfeed .= '<w:rover_name>' . $image[$i]->rover->name . '</w:rover_name>';
            $rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O", strtotime($image[$i]->earth_date)) . '</pubDate>';
            $rssfeed .= '</item>';
        }
    }
Example #2
0
<body>
<a href="https://github.com/joelgarciajr84/nasa-mars-pictures"><img style="position: absolute; top: 0; left: 0; border: 0;" src="images/fork-me.png" alt="Fork me on GitHub" data-canonical-src="images/fork-me.png"></a>

<div class="row row-header" id="top">
  <div class="container">

<?php 
if (!$Mars->CheckConnection()) {
    echo "<p align='center' class='red'></p>";
} else {
    echo "<p align='center' class='green'></p>";
}
if (isset($_POST['data_das_fotos']) && isset($_POST['select_rover'])) {
    $photosdate = $_POST['data_das_fotos'];
    $rover = $_POST['select_rover'];
    $images = json_decode($Mars->getPictures($photosdate, $rover));
}
?>
  <div class="col-lg-6 welcome">
    <h1>Welcome to Mars</h1>
    <hr>
    <p>
      Junte-se a nós na exploração a Marte. <br> Selecione ao lado o dia e qual sonda <br> espacial você deseja e visualize as fotos.
    </p>
  </div>
  <div class="box-api">
    <div align="center">
      <img align="center" src="logo.png" alt="" style=" width: 25%;">
      <img align="center" src="univale.jpg" alt="" style=" width: 25%;">
      <hr>
    </div>