Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function SetTwitterAppSettings(ByVal AppID As String, ByVal AppName As String, ByVal AppDescription As String, ByVal AppURL As String, ByVal callback_url As String, ByVal form_build_id As String, ByVal form_token As String) As String
- Dim boundary As String = "---------------------------" & DateTime.Now.Ticks.ToString("x")
- Dim newLine As String = System.Environment.NewLine
- Dim boundaryBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(newLine & "--" & boundary & newLine)
- Dim request As Net.HttpWebRequest = Net.WebRequest.Create("https://dev.twitter.com/apps/" & AppID & "/settings")
- ' Set Proxy Details
- Dim myProxy As New WebProxy(Proxy, Port)
- myProxy.Credentials = New NetworkCredential(ProxyUser, ProxyPass)
- request.Proxy = myProxy
- ' Request Settings
- request.Method = "POST"
- request.ContentType = "multipart/form-data; boundary=" & boundary
- ' request.KeepAlive = True
- request.AllowAutoRedirect = False
- request.Timeout = MaxTimeout
- request.CookieContainer = cookies
- request.UserAgent = Useragent
- request.AllowWriteStreamBuffering = False
- request.Referer = "https://dev.twitter.com/apps/" & AppID & "/settings"
- Dim ms As New MemoryStream()
- ms.Write(boundaryBytes, 0, boundaryBytes.Length)
- Dim headerTemplate As String = "Content-Disposition: form-data; name=""{0}""; description=""{1}""; url=""{2}""; files[image]""; filename=""; access_level=1; callback_url=""{3}""; organization=""""; organization_url=""""; op=""Update this Twitter application's settings""; form_build_id=""{4}""; form_token=""{5}""; form_id=""twitter_apps_form_settings""; "
- Dim header As String = String.Format(headerTemplate, AppName, AppDescription, AppURL, callback_url, form_build_id, form_token)
- MessageBox.Show(header)
- Dim headerBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(header)
- ms.Write(headerBytes, 0, headerBytes.Length)
- Dim length As Long = ms.Length
- request.ContentLength = length
- Using requestStream As IO.Stream = request.GetRequestStream()
- Dim bheader() As Byte = ms.ToArray()
- requestStream.Write(bheader, 0, bheader.Length)
- requestStream.Close()
- End Using
- Dim response As Net.WebResponse = Nothing
- Dim responseText = ""
- response = request.GetResponse()
- Using responseStream As IO.Stream = response.GetResponseStream()
- Using responseReader As New IO.StreamReader(responseStream)
- responseText = responseReader.ReadToEnd()
- End Using
- End Using
- response.Close()
- response = Nothing
- request = Nothing
- Return responseText
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement