Archive for the 'APIs' Category

Yahoo! GeoPlanet API makes backwards-incompatible change, keeps it secret?

I just noticed that the Yahoo! GeoPlanet API made an API change to its JSON API that breaks existing apps. (I noticed because it broke the sign-up process for the new Singularity teaser site.)

Googling around, I couldn't find any announcements from Yahoo! about this. I don't know if there's a notification feed somewhere that I'm missing -- if so, I'd appreciate it if someone could point me in the right direction. Otherwise, in case any other developres are using the Yahoo! GeoPlanet JSON API and are affected by this, here's a summary of the change from the post I just made on the yws-geo forum:

I just realized that you removed the 'place' array from the JSON object returned from places.q() calls (e.g., of form http://where.yahooapis.com/v1/places.q('city
name');count=0?format=json
) and that the returned places object now has the
place indices as strings.

This requires code to be changed from, for example, result['places']['place'] to result['places'] and also requires that numeric indexed loops be changed to use string indices.

It's quite baffling that a change like this (which, really, isn't even necessary) was made and not communicated. Even more so considering that the API is versioned properly (you access it from /v1/), so a change like this should really have gone into (/v2/).

I would love to hear from someone on the Yahoo! GeoPlanet team about the rationale behind this change and where we can find out about similar changes in the future.

I love the Yahoo! GeoPlanet API -- it is awesome and very simple to work with -- but please, guys, pay a bit more attention to backwards compatibility, communicate better, and don't break existing apps! :)

SWX Contest entries published!

The 19 20 22 entries that we received for the SWX Contest have now been published on the SWX Contest page for public viewing.

Due to the manageable number of entries, we're going to forego the first round of public voting (although you are welcome to leave comments on the entries) and allow our outstanding panel of judges to pick the winners from the Web, API, and Mobile categories in a single round of voting.

We received 8 9 10 entries in the web category, 3 4 in the mobile category, and we now have 8 new SWX APIs thanks to the contest, ranging from a generic XML to SWX parser called SWXml to APIs for popular services such as Wordpress, Backpack, Technorati, Kuler, and Verisign/Paypal Payments Pro.

I want to take this opportunity to thank all the contestants for their hard work. Here's wishing all of you the best of luck!

The winners will be announced on December 24th, 2007.

Also, a big thank you to our sponsors: Adobe UK, Lynda.com, Burak Kalayci (ASV), Friends of ED, and yours truly (Nabaztag bunnies and iPod Touches).

View the SWX Contest entries.

Update: I messed up and forgot to add Julio Rodriguez's entry to the Web category this morning. I've now updated the page with his entry and informed the judges. Thanks for getting in touch with me Julio and apologies for the initial omission.

Update: John Hattan's entries in the Web and Mobile categories also somehow ended up in the black hole of my email. Sorry, John, I've added them to the contest page and informed the judges now.

Web ‘08 predictions: The rise of RIAs and the 3D web

Recently, I gave a talk titled Web '07 - Web '08 at the Christmas charity dinner (linking to the Google cache as the original site appears to be down at the moment) organized by Sussex Geek Dinners. It was a lighthearted tour through the highlights of Web '07 and a look ahead to Web '08* with predictions by myself and some of my friends.

In my predictions for 2008, I talked about how we will be seeing more RIAs in 2008 -- both from Adobe and third parties -- how Silverlight is not going to have a widespread impact (although is definitely something to keep an eye on for 2009/10 and the competition is going to give Adobe a welcome push in the right direction), how mobile Flash is going to move away from Flash Lite to full-scale Flash playback on devices and how we're going to see Flash on the iPhone, how sometimes-connected applications and web/desktop hybrid applications are going to gain importance with AIR, Google Gears, etc., and how real-time 3D in Flash is going to change the aesthetics of the web.

If you've been reading my blog for a while, you might remember that last phrase. It's the same thing I uttered back in 2005 before the release of Flash 8. Back then, .Net magazine pasted my prediction on its cover and I was talking about alpha-channel video, not 3D. I think we can agree that alpha channel video in Flash has altered the aesthetics of the web in the intervening period and I am convinced that 2008 is the year that Flash is going to do the same thing with 3D thanks to Papervision3D.

Specifically, the combination of alpha-channel video, bitmap effects and filters, and real-time 3D is going to create a new benchmark in production values for online experiences. We're already seeing trailblazers like Carlos Ulloa, Ralph Hauwert, and John Grden are pushing the boundaries in this area and, in 2008, we are going to see more mainstream adoption of these techniques.

(I just read a somewhat myopic article in 3D World magazine titled "The look of 3D in 2008" that didn't even touch upon web 3D in any of its predictions! Could it be that web 3D is going to blindsight the traditional 3D community?)

To these predictions, I add two new ones that are closer to my heart: Firstly, Flash developers are going to get a lovely toy-box of APIs to work with and, secondly, we're going to witness a conference that's also going to be a technological tour-de-force to very visibly and publicly define how far we've come in Web '08. The latter has me more excited than I've been in a _very_ long time. And that's all I'm going to say about that for the moment.

The web just keeps getting more and more exciting... here's to a most wonderful 2008!

* Just as an aside, can we please drop the version numbers? We know in software that the moment an application gets its version number it's out of date. So why do we want to apply the same paradigm to describing the web? It's far more accurate, imho, to analyze the characteristics that defined the web in a given year. Hence, Web '08, not Web 3.0).

FlashBrighton’s Big Day Out: Beyond the buttons

Flash Brighton Big Day Out

Here's quick update on the session I'm presenting at FlashBrighton's Big Day Out (the event's now sold out) this Saturday. The talk is titled Beyond the Buttons:

Learning new programming languages, development tools, and technologies is a fun (and essential) part of what we do but they are not ends in and of themselves. IDEs like Flash and Flex Builder, languages like ActionScript 3, and technologies like AIR are merely tools, like the painter's brushes, easels, and paints, the animator's lightbox, and the photographer's camera. In this session, Aral looks beyond the tools to what you can make with them. You will not learn any new techniques or programming tricks but instead stock up on ideas and inspiration to spark your own creative endeavors.

Looking forward to seeing some of you this weekend!

Coming up: Mock data support and better default argument handling in the SWX Service Explorer

I'm currently working on a stealthy little pet project of mine that involves creating a PayPal Website Payments Pro API in SWX. A couple of the methods in the API require quite a few arguments (all the billing-related fields for processing a credit card transaction, for example) and I quickly got sick of having to enter mock data manually in the SWX Service Explorer to test and debug methods calls. (This is one scenario where Transfer Object support would be helpful but adding that right now would complicate things too much.) So, to make things easier for myself (and hopefully some of you as well), I've added mock data support (both static and dynamic) to SWX PHP and the SWX Service Explorer.

Using mock data

In the SWX Service Explorer, methods that have mock data will have a "Use mock data" button enabled.

Clicking the button will fill the arguments with the mock data, as the following screenshot demonstrates.

Creating static mock data

The first way to create mock data is to include it in the JavaDoc-style comments in your service classes. Place mock data at the end of the comment and surround it in square brackets.

/**
   * Do a direct credit card payment.
   *
   * @param (str) A unique order id [12345-12345]
   * @param (str) Credit card number [5105105105105100]
   * @param (str) Card type (Visa, American Express, Mastercard, etc.) [Mastercard]
   * @param (str) 3 or 4 character Credit Security Code [123]
   * @param (number, 4 digits MMYY) Expiry date [1209]
   * @param (number) Amount to charge [2.50]

This is a quick and easy way of adding mock data to a method. The recommended practice here, when possible, is to place enough mock data in a method to allow the user to make a successful call via the SWX Service Explorer. This is in keeping with the SWX philosophy of making things Just Work and Show, Don't Tell.

Generating mock data

The new mock data feature does not limit you to static mock data. You can also generate dynamic mock data with a little bit of PHP.

To generate mock data for a method called doDirectPayment(), for example, you can include a private method called _doDirectPaymentMock() in your service class. This method gets called (and passed an array of any static mock data for the method, which you can either add to or ignore) by the service explorer. It expects an array of mock data (one for each argument) to be returned as per the following example.

function _doDirectPaymentMock($mockData)
{
    // Generate a random order number
    $orderNum = '"'.date('ymd-H').rand(1000,9999).'"';
    $mockData[0] = $orderNum;
 
    return $mockData;
}

In the above example, the order number needs to be unique so it's generated by code but all the other default values are statically obtained from the comments.

Update: In the latest version of the SWX Service Explorer in SVN, the dynamic mock data now updates every time you press the Use mock data button.

Default values for optional arguments

I've also modified how default parameters are handled in the SWX Service Explorer. Previously, they were handled Really Badly (tm). i.e., they were basically ignored. Now, if your method has a default value defined, it is displayed in the SWX Service Explorer by default. This is true even if you define the default value as a constant (in PHP4, you must stick to the CONSTANT_NAMING_CONVENTIONS for constant resolution to work correctly.)

(Note that in PHP5, you must place all optional arguments at the end of your method signature. This is a best practice to follow in any case.)

The following screenshot shows how default values for arguments are handled in the new service explorer:

Currently, the changes outlined in this post are only available from the trunk of the SWX Subversion repository. I'd appreciate it if you guys can test it out. After further testing, it will be included in the next SWX PHP release.

Ted’s Pack of Cards in SWX

This demo requires Flash.

I was looking for a distraction from the PayPal integration stuff I'm working on today for my Super Secret New Project (tm) when I ran across Ted Patrick's Cards API post from yesterday and decided to quickly implement a SWX API for it.

Ted has created a very simple REST API for a deck of cards. It currently has one method which returns a shuffled deck (or decks) of cards.

The SWX API for it was a cinch to write. Here's the PHP code for it:

<?php 
 
require_once("../BaseService.php");
 
class Cards extends BaseService
{
    function shuffle($numDecks = 1, $numJokers = 0)
    {
        $url = "http://onflex.org/api/games/cards/shuffle/1/$numDecks/$numJokers";
 
        $result = $this->_call($url);
 
        $shuffledDeck = explode('|', $result);
        $timeStamp = array_shift($shuffledDeck);
 
        return (array('timeStamp' => $timeStamp, 'deck' => $shuffledDeck));
    }
}
?>

I wasn't sure if the timestamp was in there just to stop caching or whether it would be useful so I left it in :)

You can play with it online using the SWX Service Explorer on the Public SWX Gateway.

The demo SWF you see at the top of the post calls the service using the following code:

import org.swxformat.SWX;
 
var swx:SWX = new SWX();
swx.gateway = "http://swxformat.org/php/swx.php";
swx.encoding = "GET";
swx.debug = true;
 
var callDetails:Object =
{
    serviceClass: "Cards",
    method: "shuffle",
    result: [this, resultHandler]
}
 
// ... other stuff (UI, etc.)
 
swx.call(callDetails);

And, since the data is returned in a native SWF array, the result handler simply iterates over the array to display the cards:

function resultHandler(event:Object)
{
    var deck:Array = event.result.deck;
 
    for (var i:Number = 0; i < 52; i++)
    {
        var cardInit:Object = {_x: x += 50, _y: y, _width: 50, _height: 75};
        if (i%12 == 0)
        {
            cardInit._y = y += 75;
            cardInit._x = x = 0;
        }
        _root.attachMovie(deck[i], "card"+i, i, cardInit);
    }
}

Don't forget, like all the other SWX APIs, you can call this API from Flash 6+ (including FlashLite 2.0 and 2.1) using ActionScript 1 or 2 (not 3 yet).

Download the demo (zipped; 2.6MB).

The demo includes the SWX ActionScript Library which comes with other SWX sample apps that you can play with.

Introducing SWXml: XML to SWX parser

SWXml

SWXml by Florian Plag has me really excited! SWXml is a SWX API that provides a generic XML to SWX parser that can be used over SWX RPC. You can see examples, read the documentation, and download SWXml from the see the SWXml home page.

I've also added SWXml to the Public SWX Gateway so you can start using it in your applications today. Test out SWXml now using the SWX Service Explorer.

What does SWXml mean to you? It means that you can load any XML data set from the web into Flash as native objects, without _any_ client-side parsing.

You can, for example, consume RSS feeds or XML results from REST API calls.

The SWXml API has just one method, called parseXML. The parseXML method, in turn, takes just one argument: the url of an XML data source to parse. The method loads, parses, and returns the requested XML in SWX format (i.e., as native Flash objects, wrapped in a SWF) Yummy!

Florian has entered SWXml into the SWX contest in the APIs category, so there's going to be some great competition. If you haven't started on your own entry (the categories are web, mobile, and APIs), what are you waiting for? Get cracking!

For more information, documentation, and examples, and to download the package, see the SWXml home page.

Update: Florian has now recorded a screencast showing you how to use SWXml (2 min 48 sec, without sound).

SWX PHP and SWX ActionScript Library Version 1.0 Released

SWX PHP 1.0 and SWX ActionScript Library 1.0 Release Announcement

It's my great pleasure to announce that after six months of alphas and betas, SWX PHP 1.0 and SWX ActionScript Library 1.0 are now available for download.

SWX is officially out of beta!

The major changes from SWX PHP Release Candidate 1 include a revamped Start Page with new, royalty-free icons, and a friendly new list view for the Services and Flash examples folders.

I've also updated the SWX Nabaztag API so that you can now specify the voice that you want your Nabaztag bunny to talk in and you can move its ears and send it ear and LED choreographies. You can test out and use the SWX Nabaztag API and the other SWX APIs (Flickr, Twitter, etc.) directly from the Public SWX Gateway using the SWX Service Explorer.

Finally, there's a new LOG_ALL configuration option in swx_config.php that determines whether non-error (status, info, profiling) messages are written to the PHP error log. Set this to false on deployments for better performance. The setting defaults to true as it is useful for troubleshooting during development.

Update: Based on Jon MacDonald's suggestion (thanks, Jon!), I've also created a SWX PHP Deployment Bundle to make it easier for you to deploy SWX PHP to your server. Use the regular SWX PHP and SWX PHP MAMP Bundles to develop with and then deploy the lean-and-mean deployment bundle to your server. The deployment bundle is much smaller than the regular build as it doesn't contain the source code for the Flex-based tools or the sample Flash FLA files.

The release of SWX PHP 1.0 and SWX ActionScript Library 1.0 is something I've been looking forward to for quite a while now and I hope that SWX simplifies your development life and makes it as fun for you to create Flash and Flash Lite applications and mashups as it has for me.

In the next two months, I'm going to be traveling around the world to talk about SWX at FlashForward Boston, FlashForum Conference in Germany, MAX Chicago, MAX Barcelona, FITC Hollwood, MAX Japan, and Flash on the Beach in my home town of Brighton, in the UK. In addition to this, development work continues (I just made my first post-1.0 commit to the SVN repository) and will include efforts to create a Flash 9 version of SWX PHP, as well as SWX RPC implementations for Ruby, Python, J2EE, and .Net.

In the next few days, I will be releasing Internet Drafts for SWX and SWX RPC which I hope will become Informational RFCs.

Here's to Version 1.0! This is just the beginning.

Read the full release notes for SWX PHP 1.0 and download the 1.0 release.

Nabaztag just deleted all your bunny messages.

Nabaztag Does not Respect Your Data

The other day I noticed that the hundreds of messages you guys had sent to me in the past few months through the Nabaztag bunny widget on my blog had disappeared. At first I thought that it was a problem with the Nabaztag web site, a visual glitch, surely they could not have deleted them? For a web application, deleting user's data without copious amounts of notice is tantamount to shooting yourself in the foot repeatedly while yelling, "Hey, look at how unbelievably stupid I am, I don't deserve to be in business!"

Unfortunately, deleting the messages is exactly what Nabaztag did.

Here's the first response they sent to my support email:

When they are not played again, archived messages are stored for a two months period. We will now extend this period to 6 months (and also explain this rule on the website).

We really do apologize for the inconvenience.

Firstly, this is not an inconvenience. An inconvenience is your site being down for a couple of hours. Deleting people's data without informing them is a very serious matter.

Furthermore, a great number of the messages that were deleted were less than two months old. So I emailed them again and received this response:

Ok, you were refering to messages sent through the API. These only have a lifetime of one day. I'm sorry, but we cannot provide more time for these messages as they can reach (as in your case) a huge volume.

I don't know which is worse, that they delete messages after one day without telling people or that they are so dumb as to save the MP3s of the messages instead of just the text. If they did the latter, they wouldn't have a storage issue. Instead, they choose to give fuck all respect to their user's data and delete their messages.

And, contrary to what their support department maintains, it has not always been this way. My archive had hundreds of messages and none of them were deleted until the whole lot was deleted in one go the other day. They just decided to implement this policy one day and delete people's messages without even the common courtesy of giving us any warning so we could back things up.

This sucks, Nabaztag. And yes, I'm angry.

Some of you put a lot of effort into sending my some amazing messages and I was looking forward to featuring the best ones on this blog. Now they're all lost.

Nabaztag, I strongly urge you to reverse this ridiculous policy and start respecting your user's data.

Until Nabaztag wakes up, if you're using the Nabaztag API or receiving messages on your Nabaztag that you care about preserving, either have the online interface email you (so you have a backup) or save the messages in your own database before making the API call.

I personally apologize from any of you who sent me bunny messages through my widget for not backing them up and safeguarding them better. Like a fool, I trusted Nabaztag. Unlike Nabaztag, I place a great deal of importance on your creativity, time, and effort, whether in leaving me a comment on my blog or sending me witty bunny messages to brighten up my day. (And I really loved some of the clever messages you guys sent to me over the past few months.)

Nabaztag may not be sorry, but I am.

Update: I got another email this morning and it looks like things are changing. Here's what it reads:

I think I have some good news for you.

**None of your messages have been deleted.**

They are all stored, not in your received messages, not in the archived one, but in your sent messages (when using the API, you're the one sending the messages). Go to the website in the 'Sent' tab and you should see them all.

In the future I would also recommend you to turn on the e-mail notification of messages, so that you have also a copy of your messages in your e-mail (oh wait, you already did this).

Well this is a relief. I'm not entirely certain but I don't believe they were there yesterday. I am definitely sure that that's not where they used to be so this is the result of some change at some point (they used to go in the Received messages and I could archive them, in which case they would appear under the archived messages.) In any case, I'm just happy to have my messages back and now I'm going to manually go through 476 pages of messages to copy them for safekeeping. Don't you want my job?

It would be great if Nabaztag could confirm what their latest policy is with regards to messages so that we know and can plan accordingly, especially when building applications that use the API. It is in their interests to keep the messages (as text, not MP3s) indefinitely as it will also mean that people use their web site instead of using other people's sites to manage their messages in the long term.

Update: Well, I just made it to page 30 of 476 and my arms are tired from all the copy and pasting from their web site into Numbers. Can we please have a feature to back up/export these messages? Even if it's just a single page that dumps them all at once so we can copy and paste. This is going to take hours otherwise.

Update: Looks like Nabaztag's support has come through in the end. Franck from the Nabaztag Infirmary just sent me an Excel file with all the messages from the API. Thanks -- that's saved me a few hours of copy and paste! :)

SWX Twitter API for Flash and Flash Lite

I just documented the SWX Twitter API for Flash and Flash Lite on the official Twitter Development Talk group.

The SWX Twitter API gives you SWX, AMF, JSON and XML-RPC gateways to the full Twitter API as well as several custom API methods.

The easiest way to play around with the SWX Twitter API is to test it out online by using the PHP Service Browser that comes with SWX:

To see an example of a Twitter mashup created with SWX:

SWX Analyzer is a Flex 2 application that talks to SWX data SWFs that are in debug mode (dataHolderMovieClip.debug = true). It does this via LocalConnection so you can debug remote files as well as local ones.

The PHP Service Browser is a Flex 2 application that hits the SWX Twitter API using Amfphp and the AMF gateway.

One of the cool things about SWX is that it includes another open source project called Amfphp (Flash Remoting for PHP) and SWX services are compatible with Amfphp services. This means that, thanks to Amfphp, you can write a service (like the Twitter service) once and then consume it via SWX by hitting the SWX gateway, get it as AMF (Flash Remoting) by hitting the AMF gateway, or use JSON or XML-RPC.

For example, to get my last ten friend's updates as JSON, you can hit the JSON gateway that comes with SWX by hitting the following URL:

http://swxformat.org/php/json.php/Twitter.getNumFriendsUpdates/aral/1

Feel free to hit the SWX Twitter gateways on swxformat.org when creating your own Twitter mashups:

If you're interested in learning more about SWX, you can read an introduction to SWX, browse SWX documentation, and download the latest SWX Alpha.






Bad Behavior has blocked 0 access attempts in the last 7 days.