Reputation:
I am trying to build a program to login to a webpage, load up the homepage while logged in, and collect some data to use elsewhere. I can successfully login and collect the JSON response, but I want to load up the homepage in the same request and collect the data. Here's my code so far:
curl -L -XPOST "https://www.ifit.com/api/user/login" -d "[email protected]&password=passwordhere&rememberMe=false"
What do I do?
Upvotes: 0
Views: 5890
Reputation: 82
Assuming the homepage path you are referring to is /api/user/homepage then a one line command would look something like this:
curl -L -XPOST "https://www.ifit.com/api/user/{login,homepage}" -d "[email protected]&password=passwordhere&rememberMe=false"
Since you are accessing an API, which usually isn't done via browser, you won't likely have to deal with cookies as the server should be authenticating you by other means such as an Authorization header
or Access token
. You may have to extract that from the login response and pass it along in any subsequent requests with the -H
option, which you won't be able to do in one single command unless your client has already been authenticated and that token has not expired.
Upvotes: 1