Difference between revisions of "Class.jaiku.php"

From rukapedia
Jump to: navigation, search
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''class.jaiku.php''' is an PHP5 class that allows for basic interaction with [[Jaiku]].  At present the useful functionality is limited to updating your Jaiku presence programmatically.  
+
'''class.jaiku.php''' is an PHP5 class that allows for basic interaction with [[Jaiku]].  At present the useful functionality is limited to updating your Jaiku presence, and grabbing the current presence message and location for a given Jaiku user (you or someone else).  
  
Jaiku doesn't have a public API yet, so all of the magic is done be sending standard HTTP POSTs to Jaiku.com -- pretending to be a web browser, in other words.
+
Jaiku's [http://devku.org API] is new and is expected to grow in richness; I'll try to evolve this class as this happens.
  
 
==Source Code==
 
==Source Code==
Line 14: Line 14:
  
 
<code>http://svn.reinvented.net/Jaiku/JaikuPHP</code>
 
<code>http://svn.reinvented.net/Jaiku/JaikuPHP</code>
 +
 +
==Requirements==
 +
 +
The only additional code required is [http://www.criticaldevelopment.net/xml/doc.php XMLParser], required to parse the XML presence information returned by Jaiku.  This requirement may eventually be eliminated.
  
 
==Sample Usage==
 
==Sample Usage==
 +
 +
Your '''username''' and '''personal_key''' are required to use the API.
 +
 +
Your '''username''' is your regular Jaiku username.
 +
 +
Your '''personal_key''' can be obtained by first signing in to Jaiku and then visiting [http://api.jaiku.com http://api.jaiku.com].
  
 
<pre>
 
<pre>
 
require_once("class.jaiku.php");
 
require_once("class.jaiku.php");
$j = new Jaiku("username","password");
+
$j = new Jaiku("username","personal_key");
$j->GetJaikuSession();
+
$j->UpdatePresence("Hey, I'm using class.jaiku.php!",'Berlin, Germany', 329);
$j->UpdatePresence("Updating my presence from PHP!","My City, My Country",'333');
+
$p = $j->GetPresence();
 +
print_r($p);
 
</pre>
 
</pre>
  
Assuming you have a Jaiku.com account, and you substitute the proper values for "username" and "password," this code should update your Jaiku presence, location and icon: visit Jaiku.com to see if it worked.
+
This code should update your Jaiku presence, location and icon and then query Jaiku to retrieve this information and display it.
  
==Giving the Code a GUI==
+
==Known Issues==
  
If you're running OS X, you can use [http://www.bluem.net/downloads/pashua_en/ Pashua] to wrap a simple GUI around the class ([http://ruk.ca/article/3990 screen shot here]).  I've included the [http://websvn.reinvented.net/filedetails.php?repname=Jaiku&path=%2FJaikuPHP%2FJaikuGUI.php&rev=0&sc=0 source code for this]; it's easy to modify to suit your application and preferences.
+
There's no error reporting at all, so if it fails, you'll never know.
  
You can run the Pashua-based code from the command line or, if you want to go one step further, use Platypus to convert  the script into a ''bona fide'' OS X application; here's a screen shot of my settings for doing so:
+
==Release Notes==
  
[[Image:PlatypusJaiku.png]]
+
2007-04-28 - v0.15
 +
* Updated completely to use the new [http://devku.org Jaiku API] (rather than the old "hack the Javascript badge) to set and retrieve presence.  Any code that uses the old version need to be updated.
  
To get the Jaiku icon in there, I simply cut and paste it from Jaiku.com (for demonstration purposes only; if you build the app for distribution that would probably be a [http://jaiku.com/terms Bad Thing])
+
2006-01-19 - v0.13
 +
* Small bugfix: the cURL method used to request the presence message JavaScript changed from POST to GET. POST stopped working.
  
==Known Issues==
+
2006-12-24 - v0.12
 +
* The class now uses the burgeoning Jaiku API to send a presence update if you create the Jaiku object with a developer key (if you don't pass a key, the old school method is used).
 +
* References to ''jaikuname'' have been changed to ''screenname'' for consistency with the website terminology.
 +
* The GetJaikuSession function is now called automatically by UpdatePresence.
 +
 
 +
2006-12-24 - v0.11
 +
* Modified the GetPresence function so that it properly handles situations where the presence string parsed out of the JavaScript badge doesn't contain location information -- i.e. doesn't have "in..." at the end.
 +
 
 +
2006-12-23 - v0.10
 +
* Added basic "presence getting" functionality by adding the GetPresence() function.  This uses the same approach as [[JaikuAdium]] to grab presence information via the JavaScript "badge" that's constructed for every Jaiku user.
  
There's no error reporting at all, so if it fails, you'll never know.
+
2006-12-22 - v0.8
 +
* Incorporated a [http://term.ie/data/class.jaiku.php.patch patch from Andy Smith] to handle new Jaiku security features (have to retrieve and send back a value for '_nonce').

Latest revision as of 15:31, 28 April 2007

class.jaiku.php is an PHP5 class that allows for basic interaction with Jaiku. At present the useful functionality is limited to updating your Jaiku presence, and grabbing the current presence message and location for a given Jaiku user (you or someone else).

Jaiku's API is new and is expected to grow in richness; I'll try to evolve this class as this happens.

Source Code

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

You can grab the latest version of the source code using Subversion at:

svn://svn.reinvented.net/Jaiku/JaikuPHP

or

http://svn.reinvented.net/Jaiku/JaikuPHP

Requirements

The only additional code required is XMLParser, required to parse the XML presence information returned by Jaiku. This requirement may eventually be eliminated.

Sample Usage

Your username and personal_key are required to use the API.

Your username is your regular Jaiku username.

Your personal_key can be obtained by first signing in to Jaiku and then visiting http://api.jaiku.com.

require_once("class.jaiku.php");
$j = new Jaiku("username","personal_key");
$j->UpdatePresence("Hey, I'm using class.jaiku.php!",'Berlin, Germany', 329);
$p = $j->GetPresence();
print_r($p);

This code should update your Jaiku presence, location and icon and then query Jaiku to retrieve this information and display it.

Known Issues

There's no error reporting at all, so if it fails, you'll never know.

Release Notes

2007-04-28 - v0.15

  • Updated completely to use the new Jaiku API (rather than the old "hack the Javascript badge) to set and retrieve presence. Any code that uses the old version need to be updated.

2006-01-19 - v0.13

  • Small bugfix: the cURL method used to request the presence message JavaScript changed from POST to GET. POST stopped working.

2006-12-24 - v0.12

  • The class now uses the burgeoning Jaiku API to send a presence update if you create the Jaiku object with a developer key (if you don't pass a key, the old school method is used).
  • References to jaikuname have been changed to screenname for consistency with the website terminology.
  • The GetJaikuSession function is now called automatically by UpdatePresence.

2006-12-24 - v0.11

  • Modified the GetPresence function so that it properly handles situations where the presence string parsed out of the JavaScript badge doesn't contain location information -- i.e. doesn't have "in..." at the end.

2006-12-23 - v0.10

  • Added basic "presence getting" functionality by adding the GetPresence() function. This uses the same approach as JaikuAdium to grab presence information via the JavaScript "badge" that's constructed for every Jaiku user.

2006-12-22 - v0.8

  • Incorporated a patch from Andy Smith to handle new Jaiku security features (have to retrieve and send back a value for '_nonce').