PHP code example of newsdataio / newsdataapi

1. Go to this page and download the library: Download newsdataio/newsdataapi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

newsdataio / newsdataapi example snippets






use NewsdataIO\NewsdataApi;

$newsdataApiObj = new NewsdataApi(NEWSDATA_API_KEY);

# Pass your desired strings in an array with unique key
$data = array("q" => "ronaldo","country" => "ie");

$response = $newsdataApiObj->get_latest_news($data);




use NewsdataIO\NewsdataApi;

$newsdataApiObj = new NewsdataApi(NEWSDATA_API_KEY);

# Pass your desired strings in an array with unique key
$data = array("q" => "ronaldo","country" => "ie");

$response = $newsdataApiObj->news_archive($data);




use NewsdataIO\NewsdataApi;

$newsdataApiObj = new NewsdataApi(NEWSDATA_API_KEY);

# Pass your desired strings in an array with unique key
$data = array("q" => "ronaldo","country" => "ie");

$response = $newsdataApiObj->news_sources($data);