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…

Novembre 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

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.