2013-02-08 60 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); 
}