[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Posting to a page with JavaScript



Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>


http_url_post_stmf I get a "500 Internal Server Error".  When a web site is
made up of JavaScript do you need to post any differently?

Maybe. It's too open-ended of a question for me to answer. JavaScript can do just about anything, including completely rearranging and re-encoding a web form before submitting it.


"500 Internal Server Error" could mean absolutely anything.

The only thing that I've changed from the old, working site to the new one
is the URL.  I'm trying to post to https://sft-bcp.wellsfargo.com/

I just went to that page, and this is the data that the HTML code will post:


user=yourname&password=yourpass&switch=Log+In

It uses content-type: application/x-www-form-urlencoded when it posts it.

Consequently, the code you'll need to supply to HTTPAPI would look something like this:

     enc = http_url_encoder_new();
     http_url_encoder_addvar_s(enc: 'user'    : someuser );
     http_url_encoder_addvar_s(enc: 'password': somepass );
     http_url_encoder_addvar_s(enc: 'switch'  : 'Log In' );

     Where "someuser" and "somepass" are variables that contain the userid
     and password that you'll log in as.  (If you use variables for these,
     make sure you trim any extra spaces off of them.)


http_url_encoder_getptr(enc: mydata: datalen);


     rc = http_url_post( 'https://sft-bcp.wellsfargo.com/template/login'
                       : mydata
                       : datalen
                       : '/tmp/whatever.html'
                       : HTTP_TIMEOUT
                       : HTTP_USERAGENT
                       : 'application/x-www-form-urlencoded');

I don't know JavaScript but based on the HTML/JavaScript below should I be referencing a different URL or doing something differently? They haven't been a lot of help. Despite the number of times I tell them I'm doing this from a program they still tell me to click on things. Arggg! Any advice would be appreciated.

This is the problem with trying to automate a web site that was designed to be used by people, rather than by a computer program. Their help desk is structured to help people use a browser, not to help programmers emulate what the browser would do.


Have you asked them whether they offer a Web Service that you can consume? That would be a lot more straightforward than emulating a user logging into their interactive site, and it would run faster, too.

If they don't have a web service, the way you're doing it SHOULD work, but it'll be more difficult and it'll be difficult to get support.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------