gt-tech/gnews-api

GNews API package for laravel

v1.0 2021-06-19 09:41 UTC

This package is auto-updated.

Last update: 2024-12-19 17:31:39 UTC


README

A PHP client for the GNews API.

Installation

You can install GNews API by using Composer

You can use the following composer command to install it into an existing laravel project.

composer require gt-tech/gnews-api

Laravel will already register the service provider to your application because GNews API does make use of the extra laravel tag on the composer.json schema

Publish the configuration file

You can publish the configuration file of GNews API by running the following command:

php artisan vendor:publish --provider="ErgonautTM\GNewsApi\GNewsApiServiceProvider" --tag="config"

Usage

After installation and publish configuration file in your project,

Get Your API key from here

use ErgonautTM\GNewsApi\GNewsApi;
.
.
.
$newsapi = new GNewsApi();

Get TopHeadLines

$newsapi->getTopHeadLines($q, $topic, $from, $to, $max, $country, $lang);

Get Search

$newsapi->getSearch($q, $from, $to, $sort_by, $max, $country, $lang);

Get Countries

Returns an array of allowed countries

$newsapi->getCountries();

Get Languages

Returns an array of allowed languages

$newsapi->getLanguages();

Get Topics

Returns an array of allowed topics

$newsapi->getTopics();

Get SortBy

Returns an array of allowed sorts

$newsapi->getSortBy();

CONTRIBUTORS

This package is authored by George Tsachrelias.

TODO

  • PHP Unit Test