2013-02-08 58 views
2

我正在Adobe空气中开发一个简单的YouTube应用程序,到目前为止,我可以在YouTube上获得批准窗口并获取上传令牌。然而,我卡在你发送POST数据的部分与所有的信息(https://developers.google.com/youtube/2.0/developers_guide_protocol_direct_uploading在空气/ as3上创建POST请求直接上传

我已经加载我的视频数据作为bytearray,我需要的是创建包含所有信息的整个POST请求如链接中所示。 (xml原子提要,bytearray数据等)我拥有所有需要的信息,我只需要构建POST请求。

如何在as3/air中做到这一点?我是否将所有信息创建为URLVariables?哪些是标题,哪些不是?你如何将 - < boundary_string>添加到POST?你如何添加bytearra到POST?所有的帮助是高度赞赏。

谢谢!

+0

我一直发现内置的类URLLoader,URLRequest等在你谈论的细节类型方面可能有点缺乏,你可能想要使用像“as3httpclient”这样的第三方库或者这是一个更加抽象的东西:http://code.google.com/P /空气的YouTube-上传/ – shaunhusain 2013-02-09 00:48:13

回答

0

我一直做这样的事情发送时POST变量:

<fx:Declarations> 
    <s:HTTPService id="loginServ" resultFormat="text" result="onResult(event)" method="POST" url="http://www.myurl.com/login.php"/> 
</fx:Declarations> 

那么你将有两个功能,一个用于发送请求和一个用于处理结果你回来:

private function login():void{ 
    //Make a new Object to hold all of your POST variables 
    var reqInfo:Object = new Object(); 

    //Then set the properties of that Object to be each POST variable 
    reqInfo.username = "admin"; 
    reqInfo.password = "password"; 

    //Finally, send the request with the Object as the parameter 
    loginServ.send(reqInfo); 
} 

private function onResult(e:ResultEvent):void { 
    trace("Result:" + e.result); 
}