File: example.php

Recommend this page to a friend!
  Classes of Dave Smith  >  MediaStack Live PHP News Feed Wrapper  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: MediaStack Live PHP News Feed Wrapper
Get the news from around the world with MediaStack
Author: By
Last change:
Date: 11 months ago
Size: 879 bytes
 

Contents

Class file image Download
<?php
/*
example usage
mediaStack ver 1.0

You must get an API key from https://mediastack.com/product
and enter it in the marketstack.class.php file

For complete documentation on each endpoint and available paramaters
see https://mediastack.com/documentation
*/

//instantiate the class
require('mediastack.class.php');
$media = new mediaStack();

//get 10 news stories on tennis from the USA
$media->setEndPoint('news');
$media->setParam('keywords','tennis');
$media->setParam('countries','us');
$media->setParam('limit','10');

$media->getResponse();

//display stories
foreach( $media->response->data as $story ){
    echo
'<div>'.$story->published_at.': '.$story->source.' reports '.$story->title.' [<a href="'.$story->url.'" target="_blank">Full Story</a>]</div>';
    echo
'<div><p>'.$story->description.'</p></div>';
    echo
'<hr>';
}
?>

For more information send a message to info at phpclasses dot org.