Roll Your Own Plazes Launcher for OS X

From rukapedia
Revision as of 11:31, 20 February 2006 by Peter (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

It's really easy to "roll your own" GUI OS X Plazes launcher using the PlazesPHP class and Sveinbjorn Thordarson's Platypus tool.

Note that this launcher is intended to be run on your workstation, not on a server (presumably you want Plazes to register where you are, not where your server is).

Download Source Code

You can browse the source code from a browser, or grab the latest version of the source code using Subversion at:

svn://svn.reinvented.net/Plazes/PHP/PlazesPHP/launcher

or

http://svn.reinvented.net/Plazes/PHP/PlazesPHP/launcher

Requirements

  • PHP 5 (note that OS X comes with PHP 4 pre-installed; you can get a PHP 5 installer from Marc Liyanage's website.
  • PlazesPHP installed and tested
  • If you want proto-GUI functionality, grab and install Platypus.

Install

First, make sure that you've got the PlazesPHP class installed and tested (there are example scripts included with the source that you can use to test). Note that you'll need a Plazes.com 'developer key' -- you can obtain this by sending in a support request using the form on the [Plazes.com website.

Next, download the source for PlazesPHPLauncher.php and modify this section:

$plaze = new Plazes('username', 'password', 'developerkey', 'mac');

Insert your own values for username, password, and developerkey.

You should now be able to test the script from the command line. Save the updated file, make it executable like this:

chmod +x PlazesPHPLauncher.php

and the run the script like this:

./PlazesPHPLauncher.php

If all goes according to plan, you should see output like this:

Sending Plazes launch message...
Launched at 'Reinvented Office'
Sending Plazes update message...
Pausing for 4 more minutes...

The script should keep running, printing a status message every minute, and sending a Plazes.com update call every 4 minutes. If the script is operating properly, you should be able to go to Plazes.com, sign in to your account, and see that you are properly registered at the Plaze you're connected to.

Note that the script doesn't handle new Plazes -- you'll have to visit Plazes.com manually to register the details of an undiscovered Plazes.

Adding a GUI

Platypus is a handy OS X tool for wrapping a GUI around a PHP script. It's not a full GUI toolkit, but it does allow you to create a "Plazes Launcher" application that you can double-click on to launch Plazes, and facility to output the status messages to a GUI window.

First, grab Platypus and install. Then start it up, and set the following options:

  • App Name - you can set this to whatever you like, say Plazes Launcher for example
  • Script Type - set to PHP
  • Script Path - click on Select and locate the working PlazesPHPLauncher.php script you created.
  • Output - set to Text Window

Platypus.png

Click on Create and specify a location for the application bundle -- your Desktop is a handy place for now.

You should now be able to double-click on the application you just created and, if all is working properly, you should see the same output as you saw above when you ran the script from the command line:

Plazeslauncher.png