Skip to content

totop275/newsapi.library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

PHP Library for newsapi.org

This library is designed to run well on codeigniter 3. But it should run well on native PHP too.

How To Use

Codeigniter

  1. Extract library to /application/libraries
  2. Load library into your project
$this->load->library('news_reader');
  1. 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

Native PHP

  1. Extract to your project directory
  2. Load library
require('News_reader.php');
$param['api_key']='your newsapi.org api_key';
$news_reader=new News_reader($param);
  1. Do action
$news_reader->[method_name]([param]);

Method Available

  • 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

About

Library PHP for newsapi.org

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages