03.12YouTube 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.
I have found a project called as3-active-request, which enables HTTP requests using a Socket, which would let you do anything you want. I'm unsure as to the exact security policy of using the Socket, I had a hard time with XMLSocket a while back when coding a Jabber enabled Chat Client.
Basically I'm digging into the problem, I hope to have this resolved tomorrow at some point! If anybody can help me out, i'd appreciate it!
UPDATE 2008-03-13 (hey i'm 29 today!)
So after lotsa digging, fixing, playing around; it's pretty clear that doing PUT and DELETE HTTP commands from Flash Player is impossible w/o the HTTPService class from Flex. My personal problem is that just to use that class I end up with a 130k+ SWF. I use FlashDevelop, so I created a Default Project then added this code to the main class:
-
package
-
{
-
import flash.display.Sprite;
-
import mx.rpc.events.FaultEvent;
-
import mx.rpc.events.ResultEvent;
-
import mx.rpc.http.HTTPService;
-
-
public class Main extends flash.display.Sprite
-
{
-
public function Main():void
-
{
-
var videoId:String = "JKf7pPj6T7M";
-
-
var service:HTTPService = new HTTPService();
-
service.method = "GET";
-
service.url = "http://gdata.youtube.com/feeds/api/videos/" + videoId;
-
service.addEventListener(ResultEvent.RESULT, doResult);
-
service.addEventListener(FaultEvent.FAULT, doFault);
-
service.resultFormat = "text";
-
service.send( { alt:"json" } );
-
}
-
-
private function doResult(evt:ResultEvent):void
-
{
-
trace("doResult:"+evt.result);
-
}
-
-
private function doFault(evt:FaultEvent):void
-
{
-
trace("doFault:"+evt.fault);
-
}
-
}
-
}
You end up with a 130k+ file, plus it doesn't even work, saying that:
-
Error: No class registered for interface 'mx.resources::IResourceManager'.
-
at mx.core::Singleton$/getInstance()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Singleton.as:111]
-
at mx.resources::ResourceManager$/getInstance()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\resources\ResourceManager.as:83]
-
at mx.rpc.http::HTTPService$iinit()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:217]
-
at Main$iinit()[C:\work\web\New Project\classes\Main.as:14]
Whatever that means. I'm not a fan of Flex at all, I can do everything myself in pure AS3, BUT I can't do DELETE and PUT HTTP Requests with URLLoader, and using a Socket, well the documentation says clearly that:
The calling SWF file and the network resource being accessed must be in exactly the same domain. For example, a SWF file at adobe.com can connect only to a server daemon at adobe.com.
Making it useless for calls to webservices like YouTube or Flickr or others.
Basically, I'm stuck. So for now, there won't be any support for Updating and Removing calls in the YouTube Data API.
In the meantime, you can still use the library as it is, which you can find here.
Cheers!
Martin
Related posts (automatically generated):
- YouTube Data API ActionScript 3
- Youtube Data API in AS3 is ready!
- Youtube Data API AS3 - First Tutorial
- Youtube Data API AS3 - YouTubeClient functions & associated events.
- Sample Code - Using the YouTube AS3 API with the YouTube Player API

[...] The first one has a Flash CS3 tutorial and uses the JSON stuff of the Open Source AS3 library corelib. But then I realized that the new features like uploading videos where not covered yet. Then I came to the blog of the author Martin Legris who blogged that he had problems using the new API. [...]
April 2nd, 2008 at 6:02 am
AS2 compatible with Youtube API? On a personal level, great blog!
April 21st, 2008 at 9:38 am
Did you succeed in using upload function from Youtube API wit AS3?
May 6th, 2008 at 7:11 am
You have done a wonderful job in creating the API.
I tried to use your API in a Flex application.
Take a look here
http://subeesh.wordpress.com/2008/05/20/youtube-interface-in-flex/
May 20th, 2008 at 12:31 am
hi!!
i have a flash who call a youtube video, but i don’t know how can i take out the button in the video that links to youtube site…
i would like to have a nice fullscreen intro in my flash with youtube videos without possibility to click in the video, because on the top of the video i want to put a menu, contents, bla bla bla
it is possible with the api… i’ve tried something like that but is not working
ytplayer.enabled=false;
thanks a lot!!
Robert
May 23rd, 2008 at 12:52 pm
Nick: no the API is AS3 only… thanks for the comment.
May 23rd, 2008 at 1:08 pm
Robert: simply put a sprite over the video that is playing (in the same container), draw a transparent fill into it (beginFill(0,0)) and that should do it!
When you put items one over the other in AS3, unlike in AS2, it will cancel the events being fired on the elements underneath.
In AS2 you needed to catch the events on the transparent MovieClip above the one you wanted to make inactive, but not so in AS3.
Hope this helps!
May 23rd, 2008 at 1:09 pm
Romain: I haven’t tried yet, but I don’t think it’s impossible. I’ve been particularly busy lately.. I will start working on the API again in the next weeks.
May 23rd, 2008 at 1:10 pm
taht works!!!
… i am working in as2 and i made the movieclip inactive when i catched its event
thanks mlegris
May 26th, 2008 at 2:09 am
Regarding the Socket security issue, you can get around that restriction only if the network source contains a crossdomain.xml policy file that allows all ip addresses to connect to a specific port (ie 80) via the Socket class
http://gdata.youtube.com/crossdomain.xml
We just got to get Google to add this entry to their policy file
May 27th, 2008 at 4:13 pm
Oops. The comment system removed this from my previous post.
allow-access-from domain=”*” to-ports=”80″
May 27th, 2008 at 4:34 pm
Great library. Made a quick example in Flex using your library @ http://www.dehash.com/?p=75
Quick question:
in ca.newcommerce.youtube.webservice.YouTubeFeedClient
_developerKey value is hard coded, should it be replaced with the developers key or is it not used ?
-dehash
June 20th, 2008 at 11:34 am
Hi! Very nice post…
Try the new youTube API example where you can
search videos by keywords: tv, music, series, sports, entertainment, etc.
the url of tv243 is http://www.tv243.com/
Thanks for all
January 11th, 2010 at 12:16 pm