Http-access2 POSTing

Hi,
I’ve been expecting a certain eMail for some time now, and I have never
been good with waiting for mail. So, in order to have something to do to
distract me from waiting, I decided to write a script that would forward
the mail to my cellphone using SMS. I am using a German FreeSMS provider
(http://www.myskoda.de) which doesn’t expressly forbid automated use of
its services, so it’s kind of legal :wink:
So, after creating an account there, I tried writing my script, but it
doesn’t do what I want it to… I expect this is a result of my lack of
understanding of HTTP messages. I am using http-access2 to access a form
on the FreeSMS site that has the following structure:

+49 151 +49 160

After logging in [client.get(‘http://www.myskoda.de/index.html’,
{“callname” => “mylogin”, “password” => “mypass”})], which works as
expected, I try to do the following:
client.post(‘http://www.myskoda.de/emailsys/sms/sms.html’, {“network” =>
“151”, “number” => “12345678”, “msg” => text})
where text is a string that does not exceed 147 chars (that’s 160 chars
maximum in a SMS message minus the MySkoda ad). This doesn’t work: All I
get is the same site again (which is OK, it’s the same URL), but it
should say “Message sent, now 4 messages left [for this month]”, which it
doesn’t. Yes, I know that’s a kind of unusual question. Any ideas?

···


Thanks: Andi S.

Hi, I’ve been expecting a certain eMail for some time now, and I have never
been good with waiting for mail. So, in order to have something to do to
distract me from waiting, I decided to write a script that would forward the
mail to my cellphone using SMS. I am using a German FreeSMS provider
(http://www.myskoda.de) which doesn’t expressly forbid automated use of its
services, so it’s kind of legal :wink: So, after creating an account there, I
tried writing my script, but it doesn’t do what I want it to… I expect
this is a result of my lack of understanding of HTTP messages. I am using
http-access2 to access a form on the FreeSMS site that has the following
structure:

+49 151 +49 160

After logging in [client.get(‘http://www.myskoda.de/index.html’, {“callname”
=> “mylogin”, “password” => “mypass”})], which works as expected,

so sending the authentication this way works.

I try to do the following:
client.post(‘http://www.myskoda.de/emailsys/sms/sms.html’, {“network” =>
“151”, “number” => “12345678”, “msg” => text})

i don’t know this api - but is the autentication information sent
(automatically) again here? typically browsers do this for once you’ve done
it once, but i don’t know if this object does that or not?

···

On Thu, 2 Oct 2003, Andi Scharfstein wrote:

where text is a string that does not exceed 147 chars (that’s 160 chars
maximum in a SMS message minus the MySkoda ad). This doesn’t work: All I get
is the same site again (which is OK, it’s the same URL), but it should say
“Message sent, now 4 messages left [for this month]”, which it doesn’t. Yes,
I know that’s a kind of unusual question. Any ideas?


Thanks: Andi S.

====================================

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
The difference between art and science is that science is what we understand
well enough to explain to a computer. Art is everything else.
– Donald Knuth, “Discover”
~ > /bin/sh -c ‘for lang in ruby perl; do $lang -e “print "\x3a\x2d\x29\x0a"”; done’
====================================

Hi,

From: “Andi Scharfstein” calvin8@t-online.de
Sent: Thursday, October 02, 2003 8:05 PM

(http://www.myskoda.de)

I know nothing about this site but if the site use HTTP-Cookies,

client.set_cookie_store(“cookie.dat”)

before

After logging in [client.get(‘http://www.myskoda.de/index.html’,
{“callname” => “mylogin”, “password” => “mypass”})]

and

client.post(‘http://www.myskoda.de/emailsys/sms/sms.html’, {“network” =>
“151”, “number” => “12345678”, “msg” => text})

might help.

Bear in mind it’s Cookie store.

Unlink this file after executing if it works.

Regards,
// NaHi

Hi, again,

From: “NAKAMURA, Hiroshi”
Sent: Friday, October 03, 2003 12:05 AM

Bear in mind it’s Cookie store.

Unlink this file after executing if it works.

Wrong. Without calling
client.save_cookie_store
explicitly, it must not be saved.

Regards,
// NaHi

After logging in [client.get(‘http://www.myskoda.de/index.html’,
{“callname” => “mylogin”, “password” => “mypass”})], which works as
expected,

so sending the authentication this way works.

Yes. After that, it get’s stored in a cookie (sorry, forgot to post that
part).

I try to do the following:
client.post(‘http://www.myskoda.de/emailsys/sms/sms.html’, {“network”
=> “151”, “number” => “12345678”, “msg” => text})

i don’t know this api - but is the autentication information sent
(automatically) again here? typically browsers do this for once
you’ve done it once, but i don’t know if this object does that or not?

Yes, it recognizes that I am authorized to load the page. Try doing that
without logging in, you’ll get an error.
So, the cookie stuff seems to work… the problem is that the CGI doesn’t
seem to recognize or accept my input, but acts as if there was no input
at all. Hence my suspicion that I don’t handle the POST request
correctly. I’ve tried adding the login data to the request, but that
doesn’t change anything.

···

“Ara.T.Howard” ahoward@fsl.noaa.gov wrote:


Bye: Andi S.

Hi,
“NAKAMURA, Hiroshi” nakahiro@sarion.co.jp wrote in
news:00dc01c388f6$8f5376d0$04e6a8c0@sarion.co.jp:

(http://www.myskoda.de)

I know nothing about this site but if the site use HTTP-Cookies,

client.set_cookie_store(“cookie.dat”)

before

After logging in [client.get(‘http://www.myskoda.de/index.html’,
{“callname” => “mylogin”, “password” => “mypass”})]

and

client.post(‘http://www.myskoda.de/emailsys/sms/sms.html’, {“network”
=> “151”, “number” => “12345678”, “msg” => text})

might help.

Thanks for your input. I toyed around with that a bit and found out the
following:
client.set_cookie_store(“cookie.dat”) before logging on allows me to
authenticate at the server, making it a successful login. Leaving it out
leads to an error page (“Could not log in, please turn on cookies”).
As I had that line in the script before, that doesn’t change anything.
Sorry again I didn’t mention it.
I tried inserting this line before the “Send SMS” request, which changes
the script’s behaviour: The site now thinks that I have not logged on and
prompts me to do so (the error page I talked about in my other post). So,
I deleted it again.
Then, I tried changing the client.get to client.post and vice versa. This
proved more interesting:
When trying to provide login data via client.post (i.e. client.post
(‘http://www.myskoda.de/index.html’,

{“callname” => “mylogin”, “password” => “mypass”}), the server didn’t
accept the login anymore. That is, I got the same message as before
(“Could not log in”). So, something must be wrong with the POST method I
use to access the site.
I also tried changing the other POST request (Send SMS) to a GET, but
sadly, this didn’t work… in both cases, all I get is a 200 OK and the
site loads as if I hadn’t posted any data at all (except the login data
from the cookie, which obviously is still there). The errors and a
successful login are both handled by a 302 redirect (which I don’t have
to follow, as I know the URLs I want to access).
So, are there any ideas on how to do the POST request differently so it
might work?

···


Thx: Andi S.

Andi Scharfstein ascalvin8@netscape.net wrote in
news:Xns9408B9950EED0ascalvin8netscapenet@62.153.159.134:

So, are there any ideas on how to do the POST request differently so
it might work?

By the way, dumping the output of the script to STDERR shows the POST
arguments and values as a text stream, like so:

number12345678network151msgHello there, test

for {“network” => “151”, “number” => “12345678”, “msg” => text}

Is that normal? I don’t have a lot of experience with that library, nor
HTTP requests (as stated before)

···


Bye: Andi S.

Andi Scharfstein calvin8@t-online.de wrote in
news:Xns9408D49377036ascalvin8netscapenet@62.153.159.134:

By the way, dumping the output of the script to STDERR shows the POST
arguments and values as a text stream, like so:

number12345678network151msgHello there, test

for {“network” => “151”, “number” => “12345678”, “msg” => text}

Is that normal? I don’t have a lot of experience with that library, nor
HTTP requests (as stated before)

Well, http://dom.neopoleon.com/commentview.aspx/c27f3f0d-9b2c-40b8-9607-
a84ced507aa3 (Yeah, I know. Don’t say it) finally showed me how it was
done: posting “network=151&number=12345678&msg=#{text}” to the site does
seem to have the desired result. Thank you for your attention :slight_smile:

···


Bye: Andi S.

Hi,

From: “Andi Scharfstein” calvin8@t-online.de
Sent: Friday, October 03, 2003 6:07 AM

finally showed me how it was
done: posting “network=151&number=12345678&msg=#{text}” to the site does
seem to have the desired result. Thank you for your attention :slight_smile:

I’m sorry for your trouble… I seem to break the POSTing code
when I added streaming POST feature to http-access2.
I think your original code should work.

I’ll dig into the code.

Regards,
// NaHi

Hi,

From: “NAKAMURA, Hiroshi” nakahiro@sarion.co.jp
Sent: Friday, October 03, 2003 5:27 PM

finally showed me how it was
done: posting “network=151&number=12345678&msg=#{text}” to the site does
seem to have the desired result. Thank you for your attention :slight_smile:

I’m sorry for your trouble… I seem to break the POSTing code
when I added streaming POST feature to http-access2.
I think your original code should work.

I fixed it and released 2.0.1 on RAA.
http://raa.ruby-lang.org/list.rhtml?name=http-access2

http-access2 gives something like the functionality of
libwww-perl (LWP) in Ruby. (Though I’ve never used LWP :slight_smile:

Features;

  • methods like GET/HEAD/POST via HTTP/1.1.
  • asynchronous HTTP request
  • HTTPS(SSL)
  • by contrast with net/http in standard distribution;
    • you don’t have to care HTTP/1.1 persistent connection
      (http-access2 cares instead of you).
    • MT-safe
    • streaming POST
    • Cookies handling

Not supported now;

  • Cache
  • Rather advanced HTTP/1.1 usage such as Range, deflate, etc.
    (of cource you can set it in header by yourself)