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","https://www.barattalo.it/","https://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.

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…

Novembre 12, 2013

Find values recursively inside complex json objects in PHP

A PHP function to to quickly search complex, nested php structures for specific values.

Dicembre 18, 2022

Test page for Bright Links plugin

To test the plugin hover your mouse to a link, or tap the link on mobile device.

Dicembre 4, 2022

WP doesn’t send email? try this

Snippets for sending emails with Wordpress

Febbraio 8, 2020

Stop sending email to new user in WordPress admin registration

A code snippet to prevent WordPress to send notification emails when you manually create new users. It uses a pluggable function.

Novembre 1, 2019

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…

Settembre 2, 2016