Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJohn Fowler
7,913 PointsUsing POST requests to login
Can you use a POST request to login to a website like Facebook through something like telnet in the same way that the POST request was made in this video by filling out the browser form and clicking the submit button?
2 Answers
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsThere is a program called curl
, that is used a lot to do POST request from terminal.
I encountered that a lot, especially when using REST services.
For example, look here
http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request
So If you really want to do it try, because Telnet is too interactive
And people will want to send POST requests using terminal, because it is faster, and because the command can be saved, and you don't need a browser, by clicking and entering stuff.
PS. In the link above there is also a curl
request with password and login.
Sue Dough
35,800 PointsThe other post is right mentioning curl. This is how I logged in to my old apartments wifi instead of going to the routers login page everytime through the command line. Here is an example
curl --data "txtLogin=myUserName&txtPasswd=myPassWord&btnLogin=Login" http://172.12.1.1/portal/user-auth.php
And I created an alias in ~/.bashrc to make it super easy
alias logmein='curl --data "txtLogin=myUserName&txtPasswd=myPassWord&btnLogin=Login" http://172.12.1.1/portal/user-auth.php'
So all I had to do was type logmein.
See the man page for more info
man curl
You can use the network tool in your browser to figure out what params are sent in the post request.
Some sites won't accept it but most will.
John Fowler
7,913 PointsJohn Fowler
7,913 PointsThat is super helpful! Thank you! I'm a beginner and am trying to use C# to programmatically login to a website and then web test, but first I'm trying to understand what is really happening when I make GET and POST requests from a terminal. Really appreciate this!