Getting around AS3′s un-RESTful-ness

Hi Everyone,

[UPDATE Jan 19th, 2008]
I’ve just modified RESTProxy.php to handle gzip encoding from the client-side. It was quite simple. I was trying to consume web services on Discogs.com and it requires that you accept gzip encoding.. The source has been modified.

Mise en situtation
for those who have been following the development of the AS3 Youtube Data API library development, you might have seen that I hit a serious wall when I tried doing PUT and DELETE requests using flash.net.URLRequest together with flash.net.URLLoader. Simply put, it is impossible to execute such requests directly from the code library provided in Flash CS3. Some people have been trying to get around the problem using raw sockets, but will hit another wall inevitably: you are only allowed to connect raw sockets to the host that served you the .swf file. Hence, impossible to connect to gdata.youtube.com.

I had another idea, using Flex’s HTTPService inside of code compiled using Flash CS3. Hit another wall there. You can dynamically load some of Flex’s classes, like StringUtil, for example, using a Loader + the applicationDomain to get a reference to the Classes embedded in a SWF then instantiating them; but it doesn’t work on my complex Flex classes. You get weird errors, which I don’t understand. After spending a day on that, I decided it was over.

My goal was to keep this library client-side, AS3 only. I didn’t mind loading a SWF to get some of it’s classes, but I didn’t want to use a proxy on a server… and well, it can’t be done.

In comes the proxy
The idea is to provide a very general, generic proxy to help AS3 become RESTful. I had a few ideas, and in the end decided to opt for AMFPHP because of my past experience with it, and the fact that since Patrick Mineault (who has been a friend here in Montreal) has left, it seems it doesn’t get much attention. AMFPHP now talks AMF3, which I think is pretty cool.
Continue reading

YouTube Data API – new rollout

Hi Everyone,

YouTube released a few days ago a new version of their data API. You can now interact with the system; you are no longer limited to simply retreiving publicly available information. You can now

  • Add, Remove and Modify Favorites
  • Create, Modify and Delete Playlists
  • Add To, Remove From and Reorder Playlists
  • Upload, Delete and Update Videos
  • Rate and Comment Videos

To enable these actions, you need to login through the standard Google API Authentication procedure. I have succeeded in doing so, and using all the actions mentionned above that can be done using POST and GET. However I realized that with Flash CS3 you are not allowed to use PUT & DELETE http methods.
Continue reading

Youtube Data API AS3 – YouTubeClient functions & associated events.

Hi Everyone,

Before I begin, these are past posts on the same subject:

and the API can be found here: http://code.google.com/p/as3-youtube-data-api/

Today I will describe what events are associated with each YouTubeClient function call. I will also describe which Feed / Data Object is passed inside the said event. Please note that :

  • Events are in the ca.newcommerce.youtube.events package
  • Feeds are in the ca.newcommerce.youtube.feeds package
  • Data Obects are in ca.newcommerce.youtube.data package

Continue reading

Youtube Data API AS3 – First Tutorial

Hi everyone,

In this tutorial I will demonstrate how to use the YouTube Data API AS3 Library to:

  • search for videos using a keywords, categories and tags;
  • demonstrate how to distinguish between feeds returned to you by the API by using the requestId;
  • get information from the result feed, in this case a VideoFeed object. We will get the video, it’s main URL, then go through the different thumbnails available for a specific video.

Continue reading

YouTube Data API ActionScript 3

Hi Everyone,

so after a little research I found mostly outdated YouTube API’s out there. Even the ones on Adobe Labs refers to the pre-Google version of the YouTube API, which required a Key which you can’t get anymore.

So I set on a journey, a journey to build the AS3 Client Library for the YouTube Data API. 13 hours and 37 classes later, I’m about 90% done. I hardtyped everthing to make it completely auto-complete friendly. You have data-specific Iterators which spit out specific data objects, you have feeds, events, everything is a bit overkill but it makes it so you can explore everything from the auto-complete.
Continue reading