Results 1 to 4 of 4

Thread: Need Help With VB.NET HttpWebRequest Post...

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2016
    Posts
    5

    Lightbulb Need Help With VB.NET HttpWebRequest Post...

    I am a member of a forum that allows for a BUY/SELL/TRADE section where I'd like to make a couple posts a week. I'd like to use the interface of my VB.NET application to post there.

    I learned how to login to a the Rocbattl.com forum which was pretty easy to do. Here is the login string that I found in LiveHttpHeaders:

    "http://rocbattle.com/check_login.php?pg=http://rocbattle.com/index.php"

    And here is the post string for logging in through this request:

    "username=****&password=****&remember=remember&login=: undefined"

    But I don't know what to do after I login. I'm trying to create a POST to this section of the forum (BUY/SELL/TRADE): http://rocbattle.com/viewforumrb.php...21fe2c3c92b499

    So I guess my question would be; how do I carry the login cookie & submit a new post to the "BUY/SELL/TRADE" section?

    HERE IS THE CODE THAT I'M USING SO FAR:
    Code:
    Imports System.IO
    Imports System.Net
    Imports System.Text
    
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim postData As String = "username=" & TextBox1.Text & "&password=" & TextBox2.Text & "&remember=remember&login=: undefined"
            Dim tempCookies As New CookieContainer
            Dim encoding As New UTF8Encoding
            Dim byteData As Byte() = encoding.GetBytes(postData)
            Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://rocbattle.com/check_login.php?pg=http://rocbattle.com/index.php"), HttpWebRequest)
            postReq.Method = "POST"
            postReq.KeepAlive = True
            postReq.CookieContainer = tempCookies
            postReq.ContentType = "application/x-www-form-urlencoded"
            postReq.Referer = "http://rocbattle.com/check_login.php?pg=http://rocbattle.com/index.php"
            postReq.UserAgent = "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)"
            postReq.ContentLength = byteData.Length
    
            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)
            logincookie = tempCookies
            Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
    
            Dim thepage As String = postreqreader.ReadToEnd
    
            'Webbrowser show results:
            WebBrowser1.DocumentText = thepage
        End Sub

    Again, the code above successfully logs me in, but I'm not sure how to POST & create a new thread to the following link:

    http://rocbattle.com/viewforumrb.php...21fe2c3c92b499



    Here is what the POST string looks like according to LiveHTTPHeaders:

    subject=MY+SUBJECT&addbbcode20=100&helpbox=Tip%3A+Styles+can+be+applied+quickly+to+selected+text.&me ssage=MY+BODY+MESSAGE%3F&attach_sig=on&lastclick=1504576612&post=Submit&creation_time=1504576612&for m_token=7b51dd142acd764e07f198589e3dc1cc360a8664: undefined


    I also noticed that the POST STRING requires the following 3:

    lastclick=
    creation_time=
    form_token=


    And I can see that they all exist & are generated on the main thread posting page within the HTML:

    http://rocbattle.com/viewforumrb.php...21fe2c3c92b499


    How do I extract these values with the HttpWebRequest & POST it to this section of the forum? Thanks for any support.
    Last edited by si_the_geek; Sep 5th, 2017 at 10:25 AM. Reason: removed login details

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Need Help With VB.NET HttpWebRequest Post...

    The answer is you don't. That's because what you're doing is technically violating their terms & conditions, which violates the Terms of Service & AUP here.
    Your Conduct
    This Website may be used only for lawful purposes of uploading audio tracks, videos, beats, and information related to the music business. The Company specifically prohibits any use of the Website, and all users agree not to use the Website, for any purposes other than designated by the Company in its sole discretion, including but not limited to:
    ...
    Using or attempting to use any engine, software, tool, agent or other device or mechanism (including without limitation browsers, spiders, robots, avatars or intelligent agents) to navigate or search this Website other than the search engine and search agents available from Company and other generally available third party web browsers.
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: Need Help With VB.NET HttpWebRequest Post...

    It's also very stupid to post your login credentials on a public forum!

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Need Help With VB.NET HttpWebRequest Post...

    I'm afraid that as mentioned above, what you are doing is against the terms of rocbattle.com , so asking for assistance is against our terms.

    This thread is now closed, please do not create more for similar topics.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width