Push notifications from php to Android devices with Minibots Class

More than two years ago I wrote a post about sending push notifications from php to an iOS app called…

November 18, 2013

More than two years ago I wrote a post about sending push notifications from php to an iOS app called Pushme.To. That code, now, no longer works, and Pushme.to service no longer exists. Now I’m using an Android device and so, I’m going to show you how to send push notifications in a simple way to another app, for Android. The app is called Notify My Android and it’s free.

What you need:

The Minibots PHP Class is a class available on CodeCanyon for just 7$ that lets you make a lot of good stuff using small bots written in php (for example you can geo reference by IP address, you can search for images, check broken urls, decode tiny urls… push notifications… and many more).

Ok. First install the app from Google Play. This app lets you receive notifications, it’s free for 5 notifications per day (to remove the limit you have to pay just 5$).
Open the app and register a user.
Now with the same user go on the Notify My Android site and log in. Go to My Account section and click on Generate new key.
Setup is complete.

Now, download Minibots PHP Class from CodeCanyon and copy the minibots.class.php in your web application folder. Now you can notify events, such as alerts or checks, directly to your phone simply by adding the minibots.class.php and calling the notifyNma method. Here is an example in a script that could be runned by a cron job, it’s a script that uses Minibots class to call Ping-o-matic services to spread the world the new articles of a blog, then it send the results of this call to my Android device.

include("minibots.class.php");
// ...
// this code call Ping-o-matic service
// and send a push notification
// with Minibots.
$mb = new Minibots();
$output = "";
if($mb->pingomatic("Barattalo","http://www.barattalo.it/","http://www.barattalo.it/feed/")) 
	$output.="ok"; 
else 
	$output.="no!";

$mb->notifyNma(
        "your-api-key-from-notifymyandroid-site",   // api key
        "Ping-o-matic",                             // title
        $output,                                    // text
        "",                                         // link
        "YourRobot"                                 // application
);

Author

I’m a software engineer, an everyday web developer and a maker. I usually build sites with PHP, within or without WordPress. I build Internet of Things with Arduino and ESP8266. I’m the founder of Rockit.it and Dailybest.it and I’m actually the Chief Technical Officer of Better Days web agency.


Recommended

Make a cron job with IFTTT

Cron is a software utility, a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain…

November 12, 2013

Highlight text for search results in PHP

Useful code to highlight text occurences in search results or in a text. How to highlight text in a string…

September 2, 2016

How to add rel=”nofollow” to links with preg_replace()

Adding rel="nofollow" to external link is a good SEO practice.

September 22, 2015

Limit the number of categories for posts in WordPress

CHOOSE ONLY ONE CATEGORY WORDPRESS If you need to limit the number of categories used by the authors of your…

September 14, 2015

Reordering rows records on a mysql table with PHP

This PHP function lets you reorder records on a table when you have a field used for save the position.…

December 18, 2013

Scraping content with PHP as if it was jQuery

Building a spider or a bot needs some knowledge of regular expressions, you must know and use preg_match or preg_match_all…

December 8, 2013