This library is designed to run well on codeigniter 3. But it should run well on native PHP too.
- Extract library to /application/libraries
- Load library into your project
$this->load->library('news_reader');
- Do action
$this->news_reader->[method_name]([param]);
api key is saved on codeigniter config file with item name 'api_key', or can be pased through library loader or 'setApiKey' method
- Extract to your project directory
- Load library
require('News_reader.php');
$param['api_key']='your newsapi.org api_key';
$news_reader=new News_reader($param);
- Do action
$news_reader->[method_name]([param]);
- setApiKey ( [api_key] ) : Rewrite api key on the library
- getApiKey : Return current used api key
- getNews( [endpoint], [array of parameter]) :
- endpoint available: top-headlines,everything,sources
- parameter: country,category,sources,q,pageSize,page.
Note: Read more abaut endpoint and parameter availability on News API Documentation page
- results : Return success results of getNews method
- error : Return array of error information from invalid getNews command
- articles : Return list of articles from getNews command