Marius van Witzenburg We fight for our survival, we fight!

14jun/111

How to send a message to your iPhone via Pushme.to with PHP or Bash and Curl

Posted by mariusvw

After having Pushme.to installed on my iPhone for over 3 months now I finally had the time to work on some scrips to make it work in different languages for use on servers that I manage.

The PHP version is the less version I use but may be handy for some people.

PHP Version:

function pushMeTo($username, $message, $signature) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'http://pushme.to/' . $username . '/'); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, 'message=' . urlencode($message) . '&signature=' . urlencode($signature));
    curl_exec($curl);
    curl_close($curl);
}
pushMeTo('username', 'Hello world!', 'God');

A more used version is the commandline (Bash) version:

Bash version:

#!/bin/bash
username="username"
message="Hello world"
signature="God"
/usr/local/bin/curl -F "message=$message" -F "signature=$signature" "http://pushme.to/$username/"

I currently use these for server monitoring on FreeBSD like the GEOM Raid bay and S.M.A.R.T. status of the disks and website monitoring which works quite nice. And in case the internet connection drops I have a backup via SMS with a serial connected cellphone. So this should be quite failsafe :-)

If you have any other language that you want to use such as Perl just let me know and I could write it for you.

I hope you find these scripts useful. Happy texting! :-)