1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need some help PHP bot

Discussion in 'PHP & Perl' started by tantanleblanc, May 1, 2011.

  1. tantanleblanc

    tantanleblanc Newbie

    Joined:
    Dec 16, 2009
    Messages:
    3
    Likes Received:
    0
    I got the same problem as someone on stackoverflow and I don't see anything in the answers that can help me a little. So I paste his text here because I can't explain better my problem, if anybody has some ideas. I think I have a problem with the multipart/form-data but I'm not really sure about it. The only output I get after posting the data is :
    "The CAPTCHA answer provided is not correct. Please go back and try again."
    (it's recaptcha). But, I know the answer is not wrong and it should work because I got no problem with it on regular forms. So here is the post of Stackoverflow :

    Hi am trying to post some data on a website using CU RL. The posting process has 3 steps. 1. enter a U RL, submit and get to the 2nd step with some fields already completed 2. submit again, after you entered some more data and preview the form. 3. submit the final data.

    The problem is that after the second step, the form data looks like this :
    Code:
    POSTDATA =-----------------------------12249266671528
    Content-Disposition: form-data; name="title"
    
    Filme 2010, filme 2009, filme noi, programe TV, program cinema, premiere cinema, trailere filme - ss s. co
    -----------------------------12249266671528
    Content-Disposition: form-data; name="category"
    
    3
    -----------------------------12249266671528
    Content-Disposition: form-data; name="tags"
    
    filme, programe tv, program cinema
    -----------------------------12249266671528
    Content-Disposition: form-data; name="bodytext"
    
    Filme 2010, filme 2009, filme noi, programe TV, program cinema, premiere cinema, trailere filme
    -----------------------------12249266671528
    Content-Disposition: form-data; name="trackback"
    
    
    -----------------------------12249266671528
    Content-Disposition: form-data; name="url"
    
    ss s. co
    
    -----------------------------12249266671528
    Content-Disposition: form-data; name="phase"
    
    2
    -----------------------------12249266671528
    Content-Disposition: form-data; name="randkey"
    
    9510520
    -----------------------------12249266671528
    Content-Disposition: form-data; name="id"
    
    17753
    -----------------------------12249266671528--
    
    I am stuck trying to devise an algorithm that will generate this kind of POST data for the second step. Just to mention the URL of the form never changes. The url finishes by /submit. There is only a hidden input called "phase" that changes according to the step i am currently on (phase = 1, phase = 2, phase = 3). Any help, be it either code, pseudo-code or just guidance would be greatly appreciated.
     
  2. pk2002

    pk2002 Newbie

    Joined:
    May 7, 2011
    Messages:
    16
    Likes Received:
    1
    Try to pass data via array
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
     
    • Thanks Thanks x 1
  3. tantanleblanc

    tantanleblanc Newbie

    Joined:
    Dec 16, 2009
    Messages:
    3
    Likes Received:
    0
    Thanks for the help.

    The issue came from a problem on the site I was testing on. It was working on any other site. Thanks for the answer anyway. I wasted 10 hours trying to understand where the problem was...