views:

948

answers:

2

Hey guys,

I'm having some trouble devise a script which attempts a login to a billing portal (Freshbooks) using cURL. I've seen various examples of this online (http://www.trap17.com/index.php/automatic-login-curl%5Ft38162.html) however, none of these examples would with JavaScript.

The login page seems to be based on JavaScript and jquery. Can anyone point me to a helpful example? My objective is to submit via cURL login information to this page and receive a response if the login is correct or not.

Here is an example login page: https://trustxbeta.freshbooks.com/

Thanks

+1  A: 

What you want to do is look very carefully at the network traffic with Firebug. I'm sure you have some posts to deal with. cURL can handle usernames and passwords and SSL authentication. You just have to make sure you get all the settings just right.

I looked at your example. There is a POST that looks like this:

Submit  Login
forgotten   
invitation  
javascriptDisabled  0
password    hadafarm
username    OldMcDonald

I'm not sure what it looks like when you log in for real (my made-up account failed to get me in).

You'll also want to look at the headers and make sure you get all those set right (encoding and such).

Nosredna
+2  A: 

You can use Fiddler on IE, TamperData or Firebug (net) on Firefox, the inspector on Chrome and on Safari, or a proxy with any browser to watch how the form is submitted by a "normal" browser. You'll then recreate the query strings and any post data with the multitude of parameters available to curl. Curl can even store cookies from one request in a file until they're needed for the next request, which I've found very helpful.

dlamblin