I am trying to build an application where i can upload files to youtube. I have gotten OAuth working, and Youtube is returning a session!
The problem i am having is, youtube requires i make an XMLHTTP POST to get a url where i can upload through my web page.
I have no idea how to make an XMLHTTP Post with the extra parameters youtube requires. They have code samples in PHP and .net both of which i dont understand yet :(
This is where i am stuck: http://code.google.com/apis/youtube/2.0/developers_guide_protocol_browser_based_uploading.html#Sending_a_Browser_Upload_API_Request
I dont know how to Format an xml http command to have all those variables youtube wants. Please help...
here is what they want..
POST /action/GetUploadToken HTTP/1.1
Host: gdata.youtube.com
Authorization: AuthSub token="DXAA...sdb8"
GData-Version: 2
X-GData-Key: key=adf15ee97731bca89da876c...a8dc
Content-Length: 1941255
Content-Type: application/atom+xml; charset=UTF-8
<?xml version="1.0"?>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:yt="http://gdata.youtube.com/schemas/2007">
<media:group>
<media:title type="plain">Bad Wedding Toast</media:title>
<media:description type="plain">
I gave a bad toast at my friend's wedding.
</media:description>
<media:category
scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People
</media:category>
<media:keywords>toast, wedding</media:keywords>
</media:group>
</entry>
Here is the code i have now: I think i need the Headers? When i post it i get a response of not authorized. I also tried to create an old html and try that but it does not work...
Have no idea how those paramenters are sent:
Here is what i got
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP")
URLString = "http://gdata.youtube.com/action/GetUploadToken"
SendString = ""
SendString = SendString & "Authorization: AuthSub token=" & token
xmlHttp.open "POST", URLString & "?" & SendString
xmlHttp.setRequestHeader "Host:", "gdata.youtube.com"
xmlHttp.setRequestHeader "Authorization: AuthSub token=", token
xmlHttp.setRequestHeader "GData-Version:", "2"
xmlHttp.setRequestHeader "Content-Length:", "<content_length>"
xmlHttp.setRequestHeader "Content-Type", "application/atom+xml; charset=UTF-"
xmlHttp.send SendString
If xmlHttp.Status >= 400 And xmlHttp.Status <= 599 Then
Response.Write "<BR><BR><BR>Error Occured: " & xmlHttp.statusText
Else
' ReturnData = Replace(xmlHttp.responseText, "&", ",")
Response.Write "<BR><BR><BR>WENT GOOD?<BR>" & xmlHttp.responseText
End If