PHP Classes

MediaStack Live PHP News Feed Wrapper: Get the news from around the world with MediaStack

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 55 All time: 10,577 This week: 455Up
Version License PHP version Categories
mediastack 1.0GNU General Publi...5PHP 5, Web services
Description 

Author

This class can get the news from around the world with MediaStack.

It can send HTTP requests to the MediaStack API to get the last news about a given topic.

The class can take parameters that can restrict the scope of the news that you want to receive like for instance the country that is related with the news that happened, the topic categories of the news stories that are returned, or the limit number of news stories that is returned.

Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 59
All time rank: 608 in United States United States
Week rank: 32 Up4 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Example

<?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>';
}
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Usage
Accessible without login Plain text file license.txt Lic. License
Plain text file mediastack.class.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:55
This week:0
All time:10,577
This week:455Up
User Comments (1)
Very helpful for mediastack news.
3 years ago (Max Mustermann)
67%StarStarStarStar