Post example: submit

Help
jdl
2006-06-30
2013-05-30
  • jdl
    jdl
    2006-06-30

    Since the sample in the README is no longer working, I put together this example:

    $snoopy = new Snoopy;
        $submit_url = "http://localhost/edufone/register.php";
        $submit_vars["email"] = "s@edufone.com";
        $submit_vars["email2"] = "s@edufone.com";
        $submit_vars["password"] = "E";
        $submit_vars["password2"] = "E";
        $submit_vars["submitRegister"] = "submit";
        $snoopy->submit($submit_url,$submit_vars);
        print $snoopy->results;

    My register.php file has 4 input text boxes:

    <input type="text" size="30" name="email" value=""
                <?php if(isset($error)) { echo "value='$email'";} ?>
              />
    ... with the names of email, email2, password, password2

    and a submit button:
    <input name="submitRegister" type="submit" id="submit" value="Submit" align="right">

    Note: the name value pairs are just matched up--also for the submit button.

    The end of the script is from the readme file:

        $snoopy->submit($submit_url,$submit_vars);
        print $snoopy->results;

    I'm sorry that it's not to a real world example that you can access but it's easy to put together a test form and try a test script.

    There's not much documentation on what result returns. For me the only thing that's printed is the resulting webpage is displayed. I'm expecting XML data back from my actual submission. If anyone has examples of parsing through the returned XML data, please post them.

    Thanks,
    Jade

     
  • Skyler
    Skyler
    2007-02-13

    I understand how to post data to scripts, but that only returns the data from the page that the login page forwarded to. What if the login page is http://mysite.com/login.php, but I want to login and then get the data from http://mysite.com/viewsomething.php?

     
    • sharp
      sharp
      2007-02-13

      Basically you should check for any cookies sent back by server after you`ve logged in with the POST.
      Set those cookies with snoopy and the a simple GET on http://mysite.com/viewsomething.php should do the trick.

      NOTE: there might be other values which might be required to be set, so first use the browser to check out which params are sent to the server (if you have no ideea what i`m talkin about, use Mozilla Firefox with plugin "Live HTTPHeaders")

      Here`s an example of what you`re looking for:

      REQUEST FROM CLIENT:
      http://www.google.ro/search?hl=ro&q=snoopy&btnG=C%C4%83utare+Google&meta=

      GET /search?hl=ro&q=snoopy&btnG=C%C4%83utare+Google&meta= HTTP/1.1
      Host: www.google.ro
      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
      Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
      Accept-Language: en-us,en;q=0.5
      Accept-Encoding: gzip,deflate
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
      Keep-Alive: 300
      Connection: keep-alive
      Referer: http://www.google.ro/
      Cookie: PREF=ID=e9e3b3f0a6185c6d:TM=1170691871:LM=1170691871:S=OUqYOFdZwqtWuoCm

      ANSWER FROM SERVER:
      HTTP/1.x 200 OK
      Cache-Control: private
      Content-Type: text/html
      Server: GWS/2.1
      Transfer-Encoding: chunked
      Content-Encoding: gzip
      Date: Tue, 13 Feb 2007 08:29:04 GMT
      ===========================================
      Hope this helps a bit, cheers! ;)

       
      • Skyler
        Skyler
        2007-02-13

        That does help alot, but I still don't completely understand. Can you give me an example, please?