aylien/newsapi

This package is abandoned and no longer maintained. No replacement package was suggested.

The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.

3.1.0 2020-01-09 08:38 UTC

This package is not auto-updated.

Last update: 2020-08-20 11:32:03 UTC


README

The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.

Sign up at https://newsapi.aylien.com/.

For more documentation see https://newsapi.aylien.com/docs/.

Requirements

PHP 5.5 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "require": {
    "aylien/newsapi": "~3.0.0"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

    require_once('/path/to/aylien/newsapi/vendor/autoload.php');

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: app_id
$config = Aylien\NewsApi\Configuration::getDefaultConfiguration()->setApiKey('X-AYLIEN-NewsAPI-Application-ID', $_SERVER['NEWSAPI_APP_ID']);

// Configure API key authorization: app_key
$config = Aylien\NewsApi\Configuration::getDefaultConfiguration()->setApiKey('X-AYLIEN-NewsAPI-Application-Key', $_SERVER['NEWSAPI_APP_KEY']);

$apiInstance = new Aylien\NewsApi\Api\DefaultApi(
    new GuzzleHttp\Client(),
    $config
);

$opts = array(
  'title' => 'trump',
  'publishedAtStart' => 'NOW-7DAYS',
  'publishedAtEnd' => 'NOW',
  'entitiesBodyLinksDbpedia' => [
    'http://dbpedia.org/resource/Donald_Trump',
    'http://dbpedia.org/resource/Hillary_Rodham_Clinton'
  ],
  'notLanguage' => ['en'],
  'sortBy' => 'social_shares_count.facebook'
);

try {
    $result = $apiInstance->listStories($opts);
    for($i = 0; $i < sizeof($result->getStories()); $i++){
      print_r($result->getStories()[$i]->getTitle() . " / " .
        $result->getStories()[$i]->getSource()->getName() . "\n");
    }
} catch (Exception $e) {
    print_r($e->getResponseObject()->getErrors());
    echo 'Exception when calling DefaultApi->listStories: ', $e->getMessage(), "\n";
}
?>

Documentation for API Endpoints

All URIs are relative to https://api.aylien.com/news

Class Method HTTP request Description
DefaultApi listAutocompletes GET /autocompletes List autocompletes
DefaultApi listClusters GET /clusters List Clusters
DefaultApi listCoverages GET /coverages List coverages
DefaultApi listHistograms GET /histograms List histograms
DefaultApi listRelatedStories GET /related_stories List related stories
DefaultApi listStories GET /stories List Stories
DefaultApi listTimeSeries GET /time_series List time series
DefaultApi listTrends GET /trends List trends

Documentation For Models