I use an API that I first need to log in to and then I get access to view the nodes. These are the two urls that are used.
http://thewebpage.com/login.php?user=123&pass=123
http://thewebpage.com/get_nodes.php
The method im using to connect is the following
StreamConnection s = (StreamConnection)Connector.open(url);
InputStream input = s.openInputStream();
byte[] data = new byte[256];
int len = 0;
StringBuffer raw = new StringBuffer();
while( -1 != (len = input.read(data))) {
raw.append(new String(data, 0, len));
}
response = raw.toString();
When I connect to login.php I get the response from the server that im logged in, but the problem is when I call get_nodes.php I get the response “please login” because the session isn’t stored.
Is there any way to solve this so I can access the nodes?
Thanks
I finally solved it by saving the cookie data from the login and then put the cookie in the other http request like this
Get cookie
Set cookie