Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Written By Sixem
- Imports System.Net
- Imports System.Text
- Imports System.IO
- Public Class TumblrAPI
- Public Shared User_Agent As String = CStr("Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)")
- Public Shared TumblrCookies As New CookieContainer
- Public Shared Function Login(ByVal Email_ As String, ByVal Pass_ As String)
- Dim Get_Key As String = Get_Data("https://www.tumblr.com/login")
- Dim Extracted_Key As String = CStr(GetBetween(Get_Key, "data-form-key=", ">")).Replace("""", Nothing)
- Dim PostData As String = String.Format("user%5Bemail%5D={0}&user%5Bpassword%5D={1}&tumblelog%5Bname%5D=&user%5Bage%5D=&recaptcha_public_key=&recaptcha_response_field=&context=home_signup&follow=&http_referer=http://www.tumblr.com&form_key={2}&seen_suggestion=0&used_suggestion=0", Email_, Pass_, Extracted_Key)
- Post("https://www.tumblr.com/login", PostData)
- Return Get_Data("https://www.tumblr.com/dashboard")
- End Function
- Public Shared Function Get_Data(ByVal Site_ As String)
- Dim request As HttpWebRequest = DirectCast(WebRequest.Create(Site_), HttpWebRequest)
- request.CookieContainer = TumblrCookies
- Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
- Dim reader As New StreamReader(response.GetResponseStream())
- Return CStr(reader.ReadToEnd)
- End Function
- Public Shared Function Post(ByVal Site_ As String, ByVal Post_ As String)
- Dim postData As String = Post_
- Dim tempCookies As New CookieContainer
- Dim _Encryption As New UTF8Encoding
- Dim byteData As Byte() = _Encryption.GetBytes(postData)
- Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create(Site_), HttpWebRequest)
- postReq.Method = "POST"
- postReq.KeepAlive = True
- postReq.CookieContainer = tempCookies
- postReq.ContentType = "application/x-www-form-urlencoded"
- postReq.Referer = Site_
- postReq.UserAgent = User_Agent
- postReq.ContentLength = byteData.Length
- postReq.AllowAutoRedirect = True
- Dim postreqstream As Stream = postReq.GetRequestStream()
- postreqstream.Write(byteData, 0, byteData.Length)
- postreqstream.Close()
- Dim postresponse As HttpWebResponse
- postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
- tempCookies.Add(postresponse.Cookies)
- TumblrCookies = tempCookies
- Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
- Return CStr(postreqreader.ReadToEnd)
- End Function
- Public Shared Function GetBetween(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, _
- Optional ByRef startPos As Integer = 0) As String
- Dim iPos As Integer, iEnd As Integer, lenStart As Integer = strStart.Length
- Dim strResult As String
- strResult = String.Empty
- iPos = strSource.IndexOf(strStart, startPos)
- iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
- If iPos <> -1 AndAlso iEnd <> -1 Then
- strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
- End If
- Return strResult
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment