2017 © Pedro Peláez
 

project laravel-newsapi

Laravel wrapper for https://newsapi.org/

image

kirill-latish/laravel-newsapi

Laravel wrapper for https://newsapi.org/

  • Friday, May 4, 2018
  • by kirill-latish
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 300 % Grown

The README.md

Laravel Package for NewsAPI.org

Laravel wrapper for NewsAPI.org API calls. Documentation for the API can be found here, (*1)

Installation

1- Require the package via Composer in your composer.json., (*2)

{
  "require": {
    "kirill-latish/laravel-newsapi": "^1.0"
  }
}

2- Run Composer to install or update the new requirement., (*3)

$ composer install

or, (*4)

$ composer update

3- Add the service provider to your app/config/app.php file, (*5)

NewsAPI\NewsAPIServiceProvider::class,

4- Add the facade to your app/config/app.php file, (*6)

'NewsAPI' => NewsAPI\Facades\NewsAPI::class,

5- Publish the configuration file, (*7)

$ php artisan vendor:publish --provider="NewsAPI\NewsAPIServiceProvider"

6- Review the configuration file and add your key (preferably through env: 'api_key' => env('NEWSAPI_KEY') ), (*8)

config/newsapi.php

Usage

Refer to the official docs as to which calls can be made and check the calls in traits under NewsAPI\Requests., (*9)

For example, get all sources (if using facade):, (*10)

use NewsAPI;

...

$response = NewsAPI::sources()->all();

The above returns an object containing a sources array., (*11)

Get a top headlines by country and category:, (*12)


$response = NewsAPI::topHeadlines()->get([ 'country' => 'gb', 'category'=>'sports' ]);

Get all news from bbc.co.uk in English for time period from 2018-05-01 to 2018-05-04 sorted by publication date:, (*13)

        $response = NewsAPI::everything()->get([
            'language' => 'en',
            'domains'=>'bbc.co.uk',
            'from' => '2018-05-01',
            'to' => ''2018-05-04,
            'sortBy' => 'publishedAt',
        ]);

The Versions

04/05 2018

dev-master

9999999-dev

Laravel wrapper for https://newsapi.org/

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kirill Latish

laravel api framework news

04/05 2018

1.0

1.0.0.0

Laravel wrapper for https://newsapi.org/

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kirill Latish

laravel api framework news