
Use the NewsData.io PHP client library to integrate NewsData.io API into your PHP application without having to make HTTP requests directly.
Package
NewsData.io PHP PackageSOURCE CODE
NewsData.io PHP Client RepositoryInstallation
Install the official NewsData.io PHP client using pip. We recommend using a virtual environment for your projects.
Terminal
$ composer require newsdataio/newsdataapi
Usage
Import Client
Bring in the core NewsDataApiClient class.
Initialize
Authenticate with your secret API key.
Request
Fetch news with flexible parameters.
Terminal
<?php
require_once '../autoload.php';
use NewsdataIONewsdataApi;
$newsdataApiObj = new NewsdataApi(YOUR_API_KEY);
#// Pass your desired strings in an array with unique key
$data = array("q" => "ronaldo", "country" => "ie");
$response = $newsdataApiObj->get_latest_news($data);
?>Was this page helpful?