PHP Classes
elePHPant
Icontem

File: doc/example/feed.php

Recommend this page to a friend!
  Classes of Sergii Pryz  >  NASA Near Earth Orbit API Client  >  doc/example/feed.php  >  Download  
File: doc/example/feed.php
Role: Example script
Content type: text/plain
Description: Example script
Class: NASA Near Earth Orbit API Client
Get near Earth orbit object data with NASA API
Author: By
Last change:
Date: 2 years ago
Size: 1,765 bytes
 

 

Contents

Class file image Download
<?php
namespace Picamator\NeoWsClient\Example;

/**
 * Resource: GET /rest/v1/feed
 */

require_once 'app.php';
require_once
__DIR__ . '/template/neo.php';

/** @var \Picamator\NeoWsClient\Manager\Manager $manager */
$manager = $container->get('neo_ws_manager_feed_manager');

// get response
$startDate = '2016-11-24';
$endDate = '2016-11-25';
$detailed = false;

/** @var \Picamator\NeoWsClient\Request\Builder\FeedRequestFactory $requestFactory */
$requestFactory = $container->get('neo_ws_request_builder_feed_request_factory');
$request = $requestFactory->create($startDate, $endDate, ['detailed' => $detailed]);

$response = $manager->find($request);

/** @var \Picamator\NeoWsClient\Model\Api\Data\FeedInterface $data */
$data = $response->getData();

echo <<<EOT
=================================================
        NEO Feed
{$startDate} - {$endDate}
=================================================

HTTP Code |
{$response->getCode()}
Api key limit |
{$response->getRateLimit()->getLimit()}
Api key remaining |
{$response->getRateLimit()->getRemaining()}


Links
-----
Prev |
{$data->getLink()->getPrev()}
Self |
{$data->getLink()->getSelf()}
Next |
{$data->getLink()->getNext()}

Element count |
{$data->getElementCount()}


EOT;

/** @var \Picamator\NeoWsClient\Model\Api\Data\Component\NeoDateInterface $item */
foreach($data->getNeoDateList() as $item) {
    echo <<<EOT
--------------------------------
{$item->getDate()->format('Y-m-d')}
================================


EOT;

   
/** @var \Picamator\NeoWsClient\Model\Api\Data\NeoInterface $neoItem */
   
foreach($item->getNeoList() as $neoItem) {
       
showNeoDetailed($neoItem);
    }
}