Plurk AS3 Bridge

Since Plurk released it’s API last December, it’s no brainer that I, as Plurk user and Flash programmer, to try to implement Plurk functionality into Flash app.
I encounter problem with crossdomain issue (really common in this line of work
), but thanks to Plurk developer responsiveness, they already add crossdomain.xml in their site root (http://www.plurk.com/crossdomain.xml).
When developing Plurk app using AS3, I also use a very helpful class to manage API call between Flash and Plurk.
Inspired from ZeroFractal’s FacebookBridge simplicity and ease of use, I write PlurkBridge as a simple Actionscript 3 bridge class to enable easy communication between Flash app and Plurk API.
This class doesn’t wrap every Plurk API method, but instead written so it be able to call any method available.
All in all, PlurkBridge is:
- Simple
Plurk API call and handling can be done as few as two step. PlurkBridge initialization and load call (see example below). - Consistent
This PlurkBridge class remain flexible and independent from any change or update on the API by Plurk Developer.
You don’t need to learn new method/parameter here, just use Plurk API official documentation page directly. - Lightweight
PlurkBridge class itself only have 7kb in size.
Example code:
import com.harsanalif.plurkbridge.PlurkBridge;
var API_KEY:String = "myPlurkAPIKey";
var USERNAME:String = "myUsername";
var PASSWORD:String = "myPassword";
var METHOD:String = "/API/Users/login";
var bridge:PlurkBridge = new PlurkBridge();
bridge.load(METHOD, { api_key:API_KEY, username:USERNAME, password:PASSWORD }, onComplete);
function onComplete(result:Object):void
{
if(result.error_text)
{
//Error handler
trace(result.error_text);
}
else
{
//Success
trace(result.user_info.display_name);
}
}
You can see the Flash demo in action using PlurkBridge class here:
PlurkBridge Demo
You can download the source and example here:
PlurkBridge
Known issue:
- Plurk native error (invalid_login, invalid_plurk_id, etc) can only be handled correctly with Flash Player 10 because of limitation in HTTP Header handling in previous Flash Player version.
I suggest you target Flash Player 10 when using this class. - Also, as pointed by Focus1921 in his blog post, this class can’t handle image related API method, specifically, API method that need to use multi-part POST request.
I have tried various method on this but no success. For now, if you really need upload image functionality for Plurk API, you can use revised version of Plurk AS3 Bridge class by Focus1921 (LINK). Special thanks to Focus1921 for this workaround
If you can find other workaround/hack to be able to use /API/Users/updatePicture & /API/Timeline/uploadPicture in AS3, please let me know.

uhmm., can you each me how to use the Plurk API.?
(
Hi Marianne.
Plurk API using simple HTTP request that returning JSON encoded data.
Check HTPP request method on your programming language of choice, or if you using Flash CS3/CS4, just download PlurkBridge class directly and type example code above on Action panel. Of course you need to insert your own API_KEY, USERNAME, and PASSWORD.
Check http://www.plurk.com/API for more info and implementation on other programming language.
Mantep, sampai dipublikasikan plurkapi
Btw ini saya juga coba iseng buat saja
http://files.yohang.web.id/plurkflash.html
Thanks
Aplikasimu keren, simple but solid! Cocok buat widget Plurk pribadi
mau nanya mas..
kalo udah jadi aplikasinya trus diupload kmn ya ?
itu dalam bentuk formatnya apa? flash swf?
this blog is nice for solving my problems~
how will i get the API badge?
Hi Anthony,
To get API Badge on Plurk, you need to develop a public app using Plurk API, and tell Plurk team the application description and it’s link (via their Contact Form).
If you’re lucky, you’ll get the plurk badge in a moment.
.. can you teach me how to use this ? please ..
Hi Roxie,
Just download the example file above, open it with Adobe Flash CS3, enter your Plurk API key (that you can get from plurk.com/API), and you’re ready to go
If you already familiar with how working with Actionscript 3, I think it’s not that hard to understand example code above and try to write your own code.
If you have more problem, let me know.
Hi Kriz,
Kalo udah jadi bisa diupload kemana saja, seperti tempat hosting file swf kayak http://megaswf.com/ ato http://www.swfupload.com/. Tapi lebih baik kamu upload ke hostingan kamu sendiri sih kalo ada.
Yup, formatnya tetap .swf
Wow keren Mas..
Saya cobain di AIR ya..
keren banget ya
Excuse me , can you tell me how to display characters which is not english characters? They show as a block!
You’ll need to embed the non-english character on the TextField in Flash.
Sorry about this, but I’m haven’t embed non-english character for the textfield in my example app (thus showing blocky character if you used non-latin font).
keren2