A library to create, read and delete google alerts programmatically
Currently does not exist an official api for google alerts, but with this php library you can create, read or delete programmatically google alerts with a minimum effort. We have the library already implemented not only in php but in many other programming languages like c# and java, contact us for more information.
//Create a new alert for the query 'php', with default values $ga=new GAlerts('user', 'pass'); $alert=$ga->create('php'); var_dump($alert); //print out the alert data //Lists all alerts in the account $lstAlerts=$ga->getList(); var_dump($lstAlerts); //print out the array of alerts //Deletes the first alert of the account $ga->delete($lastAlerts['id']);
The library simulates the requests to the service through curl in the same way as if you were accessing with a browser. The library is a small class with around 300 lines of code and three public methods with optional parameters. The code is exhaustively tested on many different servers, php versions, languages and locations.
public function __construct($user, $pass, $timeout=30)
/** * Creates a new alert in the system * @param string $query term to search for * @param string $lang language of the searches ('en', 'ca', 'es', 'fr'...) * @param string $frequency when the alerts are refreshed. Possible values: 'day', 'week', 'happens' * @param string $type type of the returned results. Possible values: 'all', 'news', 'blogs', 'videos', 'forums','books' * @param string $quantity number of results all or just the best. Possible values: 'best', 'all' * @param string $dest destination of the alert. Possible values: 'feed', 'email' * @return boolean true when success * @throws Exception when the server returns an incorrect response */ public function create($query, $lang='en', $frequency='happens', $type='all', $quantity='best', $dest='feed')
/** * Deletes an alert from the system * @param str $idAlert Can be obtained with create() or getList() methods * @return boolean true when success * @throws Exception when the server returns an incorrect response */ public function delete($idAlert)
/** * Returns an array with all the current alerts in the system * @return array with the keys: ('id', 'type', 'term', 'url'); * @throws Exception when the server returns an incorrect response */ public function getList()
Last update: 14/06/2017
You can buy the full source code with license without limits for 28€ / 29USD
We can provide an online demo before buying, if you have any question feel free to contact us at email@example.com, we will answer immediately. If you need this or similar functionality in any other language like perl, python, ruby or even as a webservice, contact us for more information.