Critter’s Code

This is a picture of a bridge and a city. I like bridges and cities. They make me smile.

Aug-11-2009

Push notifications on your iPhone via ColdFusion

There’s an app you can purchase in Itunes App Store that will allow you to send push notifications to your Iphone. The iphone application is called “Prowl: Growl Client” You can download a plugin that integrates with Growl on the MAC (and I believe windows too) allowing you to receive copies of growl notices from your computer to your phone.

While this is all fine and dandy. Prowl also exposes an API, which allows for 1,000 notifications sent per hour per IP. The API allows for easy integration and access via ColdFusion. The possibilities of what this could be used for are endless.

I’ve created a CFC that will allow you to easily send notifications to your iphone via the Prowl servers. Actually… I’ve created two CFCs. One for ColdFusion v9.0 using (scripting FTW!1!) and a version of the CFC that uses tags.

Set your account variables and create your object:

1
2
3
4
apikey = "ei4irkfkddkdkdkdke3ie9r9r9";
providerkey = "";
callto = "<a class="linkification-ext" title="Linkification: https://prowl.weks.net/publicapi/" href="https://prowl.weks.net/publicapi/">https://prowl.weks.net/publicapi/</a>";
appname = "Critter's Code'";

// connect to the prowl cfc //
p = createObject(”component”,”ctzprowl”).init(_apikey=apikey, _callto=callto, _providerkey=providerkey, _appname=appname);

and our calls to the service:

1
2
// verify account (it does count against your 1,0000 requests per hour)
x = p.verify();

if(x.complete and x.code eq 200)
{
// send notification to devices registered to our account. //
y = p.add(priority=’0′,event=’CF9′,description=”I’m in your phone via CF9′”);
}
// dump x (our verification call)
writedump(var=x,label=’Verification results’);

if(isDefined(”y”))
{
writeoutput(’
‘);
writedump(var=y,label=’Add Notification results’);
}

Below is a screen of the dumps:

and the notification on my phone:

Basically.. for $2.99 you can program your server to send you notifications based on whatever..

I just need to finish packing a few things up with it.. and I’ll throw it up on RiaForge.

UPDATE:

I’ve uploaded the code to http://ctzprowl.riaforge.org

Itunes Link
Prowl Website (signup and generate API key)


VN:F [1.7.5_995]
Rating: 0.0/10 (0 votes cast)
VN:F [1.7.5_995]
Rating: 0 (from 0 votes)
Posted under CF9, ColdFusion, CtzProwl, Iphone, Projects
  • rudishumpert
    Verl Cool!
  • rudishumpert
    Very cool. I will have to check this out.
  • Awsome! I've been waiting for something like this. Thanks!
  • molaro
    Nice work!
  • This is awesome! However, I had to make a couple modifications to support the CF server being behind a proxy server.
  • I saw your added issue. Thanks. I'll make those changes..
  • Forgot to mention... Is it possible to get this to work with the growl desktop client?
  • I'm just tied into their external API.. and that just pushes to the Iphone.. probably not with this client..
  • robjshaw
    also check out http://cfgrowl.riaforge.org/index.cfm my co-developer did this... got it to work via the mac java api to growl via your network/desktop. I use it all the time for letting me know the results of scheduled tasks/server status etc.
  • awesome. I'll definitely give it a look. Thanks
  • jamestanner
    Im loving the idea of this, however i must be being stupid and missed something as it doesnt work for me ... ColdFusion 8.0.1...

    i edited the example.cfm and changed:

    // connect to the prowl cfc //
    p = createObject(”component”,”ctzprowl”).init(_apikey=apikey, _callto=callto, _providerkey=providerkey, _appname=appname);

    TO:

    // connect to the prowl cfc //
    p = createObject(”component”,”precf9_ctzprowl”).init(_apikey=apikey, _callto=callto, _providerkey=providerkey, _appname=appname);

    But i get an error:
    The value returned from the init function is not of type ctzprowl.

    I have created a prowl account, and obv created my API Key and placed it in the code, but no luck :(

    What i miss!??

    Many thanks in advance for any help :) and thanks for the great script
  • Hey James... easy fix.. the init function is looking for a return type of 'ctzprowl' just rename the file to ctzprowl.cfc and use the line unchanged... and it should work fine for you..
  • jamestanner
    ahha, thanks for that..... now i get "Variable PRIORITY is undefined" .... however that one i can fix :) just thought id mention it. thankyou
  • thanks.. I'll give it a look.
  • jamestanner
    I simply added <cfargument name="priority" type="String" required="true" /> underneath <cffunction name="add" access="public" output="false" returntype="struct"> (line 28)

    Next error is Variable WRITEDUMP is undefined, however, the push notification does get sent :)
    (im thinking its because writedump is a CF9 thing!?)

    Many thanks for this... great code!
  • yeah.. totally slipped my mind... it is a cf9 thing.. I'll change it up today..

    thanks, again.
  • That's interesting, especially given it's ColdFusion :)
blog comments powered by Disqus