[twitter-dev] Re: TwitVid upload function
I've discovered the same thing, it seems TwitVid is doing some weird manual parsing of variables and/or HTTP headers and everything needs to be exactly spaced as they would expect it. I had to tweak almost everything that works for other services to get it to work with TwitVid. On Jan 18, 9:03 pm, John Meyer john.l.me...@gmail.com wrote: I'm part of the TwitterVB library project. Part of my effort is to write an object that encapsulates a connection to TwitVid.com I'm currently testing the upload function but am having problems: Upload = String.Empty If DateTime.Now m_dtTL Then Me.Authenticate() End If Try Dim bMovieFile() As Byte = System.IO.File.ReadAllBytes(p_strFileName) Dim strBoundary As String = Guid.NewGuid.ToString() Dim strHeader As String = String.Format(--{0}, strBoundary) Dim strFooter As String = String.Format(--{0}--, strBoundary) Dim rqUpload As HttpWebRequest = DirectCast(WebRequest.Create(TWITVID_UPLOAD_URL), HttpWebRequest) With rqUpload .PreAuthenticate = True .AllowWriteStreamBuffering = True .ContentType = String.Format(multipart/form-data; boundary={0}, strBoundary) .Method = POST End With Dim strFileType As String = application/octet-stream Dim strFileHeader As String = [String].Format(Content-Disposition: file; name={0}; filename={1}, media, p_strFileName) Dim strFileData As String = Encoding.GetEncoding(iso-8859-1).GetString(bMovieFile) Dim strContents As New StringBuilder() With strContents .AppendLine(strHeader) .AppendLine(strFileHeader) .AppendLine([String].Format(Content-Type: {0}, strFileType)) .AppendLine() .AppendLine(strFileData) .AppendLine(strHeader) .AppendLine([String].Format(Content-Disposition: form-data; name={0}, token)) .AppendLine() .AppendLine(m_strOauth) .AppendLine(strHeader) .AppendLine([String].Format(Content-Disposition: form-data; name={0}, message)) .AppendLine() .AppendLine(p_strMessage) .AppendLine(strFooter) End With Dim bContents() As Byte = Encoding.GetEncoding(iso-8859-1).GetBytes(strContents.ToString()) rqUpload.ContentLength = bContents.Length Dim rqStreamFile As Stream = rqUpload.GetRequestStream() rqStreamFile.Write(bContents, 0, bContents.Length) Dim rspFileUpload As HttpWebResponse = DirectCast(rqUpload.GetResponse, HttpWebResponse) Dim rdrResponse As New StreamReader(rspFileUpload.GetResponseStream()) Dim strResponse As String = rdrResponse.ReadToEnd() Dim xResponse As New XmlDocument xResponse.LoadXml(strResponse) Dim xnRSP As XmlNode = xResponse.SelectSingleNode(//rsp) If xnRSP.Attributes(stat).Value = ok Then Upload = xnRSP.SelectSingleNode(//mediaurl).InnerText Else Upload = strResponse End If Catch ex As Exception MsgBox(ex.Message) End Try Return Upload End Function Calling this function gives me this error: ?xml version=1.0 encoding=UTF-8? rsp stat=fail err code=1002 msg=No file specified to upload / /rsp if anybody has any ideas I'd appreciate it (note I've put the file on the front and in the back. Both return the same error).
Re: [twitter-dev] Re: TwitVid upload function
I've changed it back to where the media file goes last and I still get that error so if anybody has an idea of what I'm doing wrong there I would appreciate it. On 1/19/2010 4:54 AM, Rich wrote: I've discovered the same thing, it seems TwitVid is doing some weird manual parsing of variables and/or HTTP headers and everything needs to be exactly spaced as they would expect it. I had to tweak almost everything that works for other services to get it to work with TwitVid. On Jan 18, 9:03 pm, John Meyerjohn.l.me...@gmail.com wrote: I'm part of the TwitterVB library project. Part of my effort is to write an object that encapsulates a connection to TwitVid.com I'm currently testing the upload function but am having problems: Upload = String.Empty If DateTime.Now m_dtTL Then Me.Authenticate() End If Try Dim bMovieFile() As Byte = System.IO.File.ReadAllBytes(p_strFileName) Dim strBoundary As String = Guid.NewGuid.ToString() Dim strHeader As String = String.Format(--{0}, strBoundary) Dim strFooter As String = String.Format(--{0}--, strBoundary) Dim rqUpload As HttpWebRequest = DirectCast(WebRequest.Create(TWITVID_UPLOAD_URL), HttpWebRequest) With rqUpload .PreAuthenticate = True .AllowWriteStreamBuffering = True .ContentType = String.Format(multipart/form-data; boundary={0}, strBoundary) .Method = POST End With Dim strFileType As String = application/octet-stream Dim strFileHeader As String = [String].Format(Content-Disposition: file; name={0}; filename={1}, media, p_strFileName) Dim strFileData As String = Encoding.GetEncoding(iso-8859-1).GetString(bMovieFile) Dim strContents As New StringBuilder() With strContents .AppendLine(strHeader) .AppendLine(strFileHeader) .AppendLine([String].Format(Content-Type: {0}, strFileType)) .AppendLine() .AppendLine(strFileData) .AppendLine(strHeader) .AppendLine([String].Format(Content-Disposition: form-data; name={0}, token)) .AppendLine() .AppendLine(m_strOauth) .AppendLine(strHeader) .AppendLine([String].Format(Content-Disposition: form-data; name={0}, message)) .AppendLine() .AppendLine(p_strMessage) .AppendLine(strFooter) End With Dim bContents() As Byte = Encoding.GetEncoding(iso-8859-1).GetBytes(strContents.ToString()) rqUpload.ContentLength = bContents.Length Dim rqStreamFile As Stream = rqUpload.GetRequestStream() rqStreamFile.Write(bContents, 0, bContents.Length) Dim rspFileUpload As HttpWebResponse = DirectCast(rqUpload.GetResponse, HttpWebResponse) Dim rdrResponse As New StreamReader(rspFileUpload.GetResponseStream()) Dim strResponse As String = rdrResponse.ReadToEnd() Dim xResponse As New XmlDocument xResponse.LoadXml(strResponse) Dim xnRSP As XmlNode = xResponse.SelectSingleNode(//rsp) If xnRSP.Attributes(stat).Value = ok Then Upload = xnRSP.SelectSingleNode(//mediaurl).InnerText Else Upload = strResponse End If Catch ex As Exception MsgBox(ex.Message) End Try Return Upload End Function Calling this function gives me this error: ?xml version=1.0 encoding=UTF-8? rsp stat=fail err code=1002 msg=No file specified to upload / /rsp if anybody has any ideas I'd appreciate it (note I've put the file on the front and in the back. Both return the same error).
[twitter-dev] Re: TwitVid upload function
I don't understand that code. I'm a PHP/MySQL kinda guy ... but if you're having problems with TwitVid - just use Twicli's API. http://twic.li/api - support for photos/videos/audio/sets I don't see the point in separating content over various different sites. The internet is enough of a mess already :) -Sam On Jan 19, 1:42 pm, John Meyer john.l.me...@gmail.com wrote: I've changed it back to where the media file goes last and I still get that error so if anybody has an idea of what I'm doing wrong there I would appreciate it. On 1/19/2010 4:54 AM, Rich wrote: I've discovered the same thing, it seems TwitVid is doing some weird manual parsing of variables and/or HTTP headers and everything needs to be exactly spaced as they would expect it. I had to tweak almost everything that works for other services to get it to work with TwitVid. On Jan 18, 9:03 pm, John Meyerjohn.l.me...@gmail.com wrote: I'm part of the TwitterVB library project. Part of my effort is to write an object that encapsulates a connection to TwitVid.com I'm currently testing the upload function but am having problems: Upload = String.Empty If DateTime.Now m_dtTL Then Me.Authenticate() End If Try Dim bMovieFile() As Byte = System.IO.File.ReadAllBytes(p_strFileName) Dim strBoundary As String = Guid.NewGuid.ToString() Dim strHeader As String = String.Format(--{0}, strBoundary) Dim strFooter As String = String.Format(--{0}--, strBoundary) Dim rqUpload As HttpWebRequest = DirectCast(WebRequest.Create(TWITVID_UPLOAD_URL), HttpWebRequest) With rqUpload .PreAuthenticate = True .AllowWriteStreamBuffering = True .ContentType = String.Format(multipart/form-data; boundary={0}, strBoundary) .Method = POST End With Dim strFileType As String = application/octet-stream Dim strFileHeader As String = [String].Format(Content-Disposition: file; name={0}; filename={1}, media, p_strFileName) Dim strFileData As String = Encoding.GetEncoding(iso-8859-1).GetString(bMovieFile) Dim strContents As New StringBuilder() With strContents .AppendLine(strHeader) .AppendLine(strFileHeader) .AppendLine([String].Format(Content-Type: {0}, strFileType)) .AppendLine() .AppendLine(strFileData) .AppendLine(strHeader) .AppendLine([String].Format(Content-Disposition: form-data; name={0}, token)) .AppendLine() .AppendLine(m_strOauth) .AppendLine(strHeader) .AppendLine([String].Format(Content-Disposition: form-data; name={0}, message)) .AppendLine() .AppendLine(p_strMessage) .AppendLine(strFooter) End With Dim bContents() As Byte = Encoding.GetEncoding(iso-8859-1).GetBytes(strContents.ToString()) rqUpload.ContentLength = bContents.Length Dim rqStreamFile As Stream = rqUpload.GetRequestStream() rqStreamFile.Write(bContents, 0, bContents.Length) Dim rspFileUpload As HttpWebResponse = DirectCast(rqUpload.GetResponse, HttpWebResponse) Dim rdrResponse As New StreamReader(rspFileUpload.GetResponseStream()) Dim strResponse As String = rdrResponse.ReadToEnd() Dim xResponse As New XmlDocument xResponse.LoadXml(strResponse) Dim xnRSP As XmlNode = xResponse.SelectSingleNode(//rsp) If xnRSP.Attributes(stat).Value = ok Then Upload = xnRSP.SelectSingleNode(//mediaurl).InnerText Else Upload = strResponse End If Catch ex As Exception MsgBox(ex.Message) End Try Return Upload End Function Calling this function gives me this error: ?xml version=1.0 encoding=UTF-8? rsp stat=fail err code=1002 msg=No file specified to upload / /rsp if anybody has any ideas I'd appreciate it (note I've put the file on the front and in the back. Both return the same error).
Re: [twitter-dev] Re: TwitVid upload function
On 1/19/2010 8:54 AM, Sam Street wrote: I don't understand that code. I'm a PHP/MySQL kinda guy ... but if you're having problems with TwitVid - just use Twicli's API. http://twic.li/api - support for photos/videos/audio/sets I don't see the point in separating content over various different sites. The internet is enough of a mess already :) -Sam Thanks. I may just add that API on in.