Deprecated: Calling get_class() without arguments is deprecated in /var/www/html/wp-includes/class-wp-http.php on line 329
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-includes/class-wp-http.php:329) in /var/www/html/wp-includes/feed-rss2.php on line 8
Check it out: https://newsapi.org/
Documentation: https://newsapi.org/docs
They didn’t have a PHP wrapper, and I was getting bored, so I scribbled a wrapper using curl to use it in PHP applications.
Add the API Key Generated using a Free Account(it has some limitations).
Look at the documentation to see the usage, as all I do is pass the same parameters to the curl request.
include 'config.php'; #set the api key here#
$newsAPIClient = new newsAPIClient;
$topHeadlines = $newsAPIClient->getSources(array('country' => 'in'));
$topHeadlines = $newsAPIClient->getEverything(array('q' => 'bitcoin', 'pageSize' => 5));
You can download the sourcecode here.
There is no warranty associated and is not intended for production use. I would add some comments and format code before use.
]]>