aylien/newsapi

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.


Keywords
php, rest, api, sdk, openapi, openapitools, openapi-generator, api-client, aylien, aylien-news-api, machine-learning, news, nlp, rest-api, text-analysis
License
Unlicense

Documentation

AYLIEN News API - PHP SDK

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