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.
]]>if($var ==5) or if (5==$var)?
Why?
Although, you might see a warning in your IDE, it’s unlikely you will get any error for saying if($var = 5) , but if you have a habit of using the other way, you will get an error for assigning variable to constant.
<?php
if($var == 5){}
if(5==$var){}
because, you may do this > if($var=5){}
and only this will generate error > if(5=$var){}
Happy Coding!
]]>