Jump to content


Photo

Http Dll 2


  • Please log in to reply
156 replies to this topic

#41 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 309 posts

Posted 24 August 2011 - 04:05 AM

Hello.
I'm quite interested in your really cool http request functions especially being able to set post parameters, that's pretty awesome. Now I understand how to do text box forms pretty well but I was wondering if you would be able to check radio boxes? to my understanding the display text is the value and they have another variable called checked and it has to be set to "checked." I'm not sure how to do this with your DLL. Any help is appreciated!

ThanX
RobotiX
  • 0

#42 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 24 August 2011 - 09:35 AM

Radio boxes all have the same name but a different value. You should look at the HTML source of the web page to find the correct values. For example:
<input type="radio" name="test" value="1"> Option 1<br>
<input type="radio" name="test" value="2"> Option 2<br>
<input type="radio" name="test" value="3"> Option 3<br>
So if you want to select option 2, you should do this:
httprequest_set_post_parameter(request, "test", "1");

  • 0

#43 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 309 posts

Posted 25 August 2011 - 04:59 AM

That's what I thought and I am still unable to make it work, it might be something wrong with other parts of my code... Someone wrote a script for sending txt messages using your dll by using http://wwww.txtdrop.com/ Its pretty simple in concept and easy to use. I thought I would try the same with http://www.pixdrop.com/ so I could send pictures to my cell phone. This would have a variety of applications but PixDrop has radio buttons and a file upload form so its a little less straight forward. But I suppose you are correct, the radio form is
<input name="group1" value="Verizon" type="radio">
It must be my attempt at the file upload form... Which I'm not sure how to take care of.

ThanX
RobotiX
  • 0

#44 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 26 August 2011 - 08:15 PM

Can you post the code you're using now?
  • 0

#45 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 309 posts

Posted 27 August 2011 - 12:45 AM

Sure thing.
Here is the code for TxtDrop, works flawlessly.
//argument0: (string) 10 Digit Phone Number
//argument1: (string) Message
//argument2: (string) Return E-mail address
txt_req=httprequest_create();
httprequest_set_post_parameter(txt_req, "submit", "Send");
httprequest_set_post_parameter(txt_req, "submitted", "1");
httprequest_set_post_parameter(txt_req, "body", argument1);
num=argument0;
num=string_digits(num);
area_code=string_copy(num, 1, 3);
exchange=string_copy(num, 4, 3);
num=string_copy(num, 7, 4);
httprequest_set_post_parameter(txt_req, "npa", area_code);
httprequest_set_post_parameter(txt_req, "exchange", exchange);
httprequest_set_post_parameter(txt_req, "number", num);
httprequest_set_post_parameter(txt_req, "emailfrom", argument2);
httprequest_connect(txt_req, "http://www.txtdrop.com/",1);
while (httprequest_get_state(txt_req)>0 && httprequest_get_state(txt_req)<4)
{
    httprequest_update(txt_req);
}
httprequest_destroy(txt_req);

And here is my attempt at PixDrop.
//argument0 (string) 10 Digit Phone Number
//argument1 (string) Carrier: "Verizon", "At&t", "Sprint", or "T-Mobile"
//argument2 (string) Filename
pix_req=httprequest_create();
httprequest_set_post_parameter(pix_req, "genit", "Send Your Picture Message");
httprequest_set_post_parameter(pix_req, "group1", argument1);
httprequest_set_post_parameter(pix_req, "userfile", argument2);
num=argument0;
num=string_digits(num);
httprequest_set_post_parameter(pix_req, "to", num);
httprequest_connect(pix_req, "http://www.pixdrop.com/",1);
while (httprequest_get_state(pix_req)>0 && httprequest_get_state(pix_req)<4)
{
    httprequest_update(pix_req);
}
httprequest_destroy(pix_req);

I think it might be because there is a file being uploaded I need to use a buffer but I don't know the uploaded file name and I'm not sure how to use the buffers.
Thanks for taking the time to figure this out.

RobotiX
  • 0

#46 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 28 August 2011 - 02:14 PM

You can use httprequest_set_post_parameter_file to upload files. Some of the carrier values were also wrong, the correct values are
"Verizon", "AT&T", "Sprint", "Tmobile"

I think this should work:
//argument0 (string) 10 Digit Phone Number
//argument1 (string) Carrier: "Verizon", "AT&T", "Sprint", or "Tmobile"
//argument2 (string) Filename

var pix_req, num, b, st;

b = buffer_create();
if (!buffer_read_from_file(b, argument2)) {
    buffer_destroy(b);
    return false; // file does not exist
}

pix_req=httprequest_create();

num=string_digits(argument0);
httprequest_set_post_parameter(pix_req, "group1", argument1);
httprequest_set_post_parameter(pix_req, "to", num);
httprequest_set_post_parameter(pix_req, "MAX_FILE_SIZE", 200000);
httprequest_set_post_parameter(pix_req, "genit", "Send Your Picture Message");

httprequest_set_post_parameter_file(pix_req, "userfile", filename_name(argument2), b);
buffer_destroy(b);

httprequest_connect(pix_req, "http://www.pixdrop.com/", 1);
while (true) {
    httprequest_update(pix_req);
    st = httprequest_get_state(pix_req);
    if (st=4 or st=5) {
        break;
    }
    sleep(10);
}

httprequest_destroy(pix_req);
return (st=4);

  • 0

#47 Buff-Robotix

Buff-Robotix

    Who Took My Pants!?!

  • GMC Member
  • 309 posts

Posted 01 September 2011 - 03:37 AM

PixDrop was really slow yesterday, better today but, sadly, your code doesn't work :(
It looked so nice too...
  • 0

#48 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 01 September 2011 - 12:26 PM

Did you try to read the message body to find out what pixdrop says?

Also, are you sure the phone number should be entered without the '-' characters?

Recipients mobile number: (i.e 212-867-5309)

Maybe it will work if you try it without string_digits?
  • 0

#49 Dom83

Dom83

    GMC Member

  • GMC Member
  • 138 posts

Posted 10 September 2011 - 06:56 PM

At last I found a download dll that I really like ! :)

I'd like to use it with a website where I need to get logged in before accessing... how can I do that with this dll ? Do you have an idea ?
  • 0

#50 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 11 September 2011 - 11:18 AM

At last I found a download dll that I really like ! :)

I'd like to use it with a website where I need to get logged in before accessing... how can I do that with this dll ? Do you have an idea ?

The easiest way to find out how this works is to install a browser plugin that can log the HTTP requests. If you're using Firefox you can try 'HttpFox'. Tell the plugin to log the HTTP requests, and then log in to the website as usual and do whatever action you want the program to perform later. Afterwards you can read the HTTP requests log to find out what parameters the browser is sending. For every page, you should find out:
- what url the browser connects to (easy)
- what GET and POST parameters are sent by the browser
- what cookies are sent by the browser
Once you know all this, you can use the DLL to imitate the requests.
  • 0

#51 Dom83

Dom83

    GMC Member

  • GMC Member
  • 138 posts

Posted 12 September 2011 - 11:35 PM

Ok, I recorded with httpfox, then I copied the Request Headers and Values :

httprequest = httprequest_create();
httprequest_set_request_header(httprequest, '(Request-Line)', 'GET /forum/viewtopic.php?t=291 HTTP/1.1', 0);
httprequest_set_request_header(httprequest, 'Host', '<the website I try to access>', 0);
httprequest_set_request_header(httprequest, 'User-Agent', 'Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2', 1);
httprequest_set_request_header(httprequest, 'Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 1);
httprequest_set_request_header(httprequest, 'Accept-Language', 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3', 1);
//httprequest_set_request_header(httprequest, 'Accept-Encoding', 'gzip, deflate', 1);
/* I had to disable this one or the html I got was coded and unreadable to me */
httprequest_set_request_header(httprequest, 'Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 1);
httprequest_set_request_header(httprequest, 'DNT', '1', 1);
//httprequest_set_request_header(httprequest, 'Connection', 'keep-alive', 1);
httprequest_set_request_header(httprequest, 'Cookie', '<the values>', 1);
state = "";
progress = 0;
filesize = 0;
downloadspeed = 0;
previoustime = current_time;
previoussize = 0;
httprequest_connect(httprequest, <the url I try to access>, false);
But I still get this page as no logged in... :unsure: I guess I'm doing it the wrong way.

Edited by Dom83, 12 September 2011 - 11:39 PM.

  • 0

#52 Maarten Baert

Maarten Baert

    GMC Member

  • GMC Member
  • 714 posts
  • Version:GM8.1

Posted 13 September 2011 - 10:27 PM

The only header you need is the cookie, you can ignore the other headers.
  • 0

#53 Dom83

Dom83

    GMC Member

  • GMC Member
  • 138 posts

Posted 13 September 2011 - 11:28 PM

:( It still does not work... I still get the page as non-logged... The values look like this :
httprequest_set_request_header(httprequest, 'Cookie', 'phpBB2_forum___tt=1315855026; phpBB2_forum___f=a%3A0%3A%7B%7D; phpBB2_forum___uf=1315438704; <and so on> ...', 1);
Where is my error ?

Edited by Dom83, 13 September 2011 - 11:31 PM.

  • 0

#54 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 15 September 2011 - 04:50 PM

There's a good chance that for a login system, the cookies are session variables. Meaning they're one-time use. So you can't just send the same cookies over again and expect it to work.

Instead, you'll need to send a login request (that is, the request your browser sends when you actually press the Login button). The site should send information back, including the cookies you'll need to send from that point on to let the site know you're already logged in.

-IMP

Edited by IceMetalPunk, 15 September 2011 - 04:50 PM.

  • 0

#55 Dom83

Dom83

    GMC Member

  • GMC Member
  • 138 posts

Posted 15 September 2011 - 09:38 PM

You must be right, I finally got it to work on some other websites but I still can't with this one. I don't find how to get the new cookies values from the website, it only gives me the htlm page. How do you do that ?

Edited by Dom83, 15 September 2011 - 09:39 PM.

  • 0

#56 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 15 September 2011 - 10:36 PM

You'd use the httprequest_find_response_header(...) function with the httprequest_get_response_header_value(...) to get the value of the "Cookie" header. You have to parse that yourself, but it shouldn't be too hard using GM's own string functions.

-IMP
  • 0

#57 Dom83

Dom83

    GMC Member

  • GMC Member
  • 138 posts

Posted 15 September 2011 - 11:44 PM

Ok. I did spy with HttpFox while I logged-in. So I did add the 4 values I got to a request to the login page :
httprequest_set_post_parameter(httprequest, "username", "<my user name>");
httprequest_set_post_parameter(httprequest, "password", "<my pw>");
httprequest_set_post_parameter(httprequest, "redirect", "");
httprequest_set_post_parameter(httprequest, "login", "Log in");

Then when the download of this login page had succeed, I get the cookies from the header infos, this way :
    new_cookies = "";
    nb_responses = httprequest_get_response_header_count(httprequest) ;
    for ( i=0 ; i<=nb_responses ; i+=1 )
    {
        response_temp = httprequest_get_response_header_value(httprequest, i);
        if ( string_count( 'domain=' , response_temp ) )
        {
            end_of_cookie = string_pos( ';' , response_temp ) ;
            response_temp = string_copy( response_temp , 0 , end_of_cookie ) ;
            new_cookies = new_cookies + response_temp ;
        }
    }
    show_message( new_cookies ) ; /* the value it shows me looks ok */

And then, to get the page I was trying to get, I use :
httprequest_set_request_header(httprequest, 'Cookie', new_cookies, 0);

But I still get the page as non-logged in.... Where is my error ? :confused:

Edited by Dom83, 15 September 2011 - 11:50 PM.

  • 0

#58 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9259 posts
  • Version:Unknown

Posted 16 September 2011 - 12:25 AM

Try this:

new_cookies = "";
cookies = httprequest_find_response_header(httprequest, "Cookie") ;
new_cookies = httprequest_get_response_header_value(httprequest, cookies);
show_message(new_cookies);

See if that works instead. Note that a cookie does not end at a semi-colon; the cookies continue on to the end of the Cookie header and must all be sent to replicate the browser's request.

-IMP
  • 0

#59 Dom83

Dom83

    GMC Member

  • GMC Member
  • 138 posts

Posted 16 September 2011 - 10:49 PM

No it does not work. :( And show_message(new_cookies); only says "Fri, 16 Sep 2011 21:46:40 GMT".
I also tried with my code but without cutting after the ";" and same... :(
  • 0

#60 Dom83

Dom83

    GMC Member

  • GMC Member
  • 138 posts

Posted 17 September 2011 - 03:16 PM

At last I got it to work ! :)
I explain for those who may have same problem some day.
The two cookies the website responses were "Set-Cookie phpBB2_forum_data=..." and "Set-Cookie phpBB2_forum_sid=..." .
They were twice in the header, number 3 and 4, and 6 and 7, and I was taking them all.
I guessed it was no good to have twice same cookies.
So I tried taking only 3 and 4 and it failed...
Then I tried taking only 6 and 7, and... it works !!! :)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users