You're very welcome! This community is great, and so is Google (although I don't work for them. ;))
Cheers, Philippe On Mon, Feb 28, 2011 at 7:55 AM, cyberalgo rythms <cyberalgoryt...@gmail.com> wrote: > Hello again: > I just want to thank you again for the super help! > I am now able to remote login using GAE for java. I am able to retrieve the > information from the pages I want. Instead of using the POST method I use > the GET method to login and call the method as many times as I need with new > URLs to fetch the pages I want but definitely the help on how to get the > cookie header and use it in the subsequent fetches was precious so thanks > again for the super google help. ;-) > best regards! > On Fri, Feb 25, 2011 at 6:51 PM, cyberalgo rythms > <cyberalgoryt...@gmail.com> wrote: >> >> Hi: >> The URL which comes in the response variable is the login page. All the >> fields there are populated according to setPayload field values but the >> password does not get populated ? >> I posted a new thread for this as it might not be related to this one. >> Thank you >> >> On Fri, Feb 25, 2011 at 6:22 PM, Philippe Beaudoin >> <philippe.beaud...@gmail.com> wrote: >>> >>> I don't know about that... Have you tried checking the URL accessed >>> when you manually fill the form and click submit? >>> >>> Cheers, >>> >>> Philippe >>> >>> On Fri, Feb 25, 2011 at 9:30 AM, cyberalgo rythms >>> <cyberalgoryt...@gmail.com> wrote: >>> > Thank you for the super help. It is first time I using this interface. >>> > I did use your code and modified a bit and I believe got the cookie >>> > working. >>> > Why i say that because after accessing the second fetch and in the view >>> > source code of the page somewhere inside uses the PHPSESSID i have >>> > retrieved >>> > from the login URL page. That indicates me i succeed in tracking the >>> > session >>> > id used. >>> > The cookie and the value I send back to the server looks like this but >>> > may >>> > de different for other servers. >>> > Cookie: PHPSESSID=sfs3892jhfsdkfsldfjsldkfjdfsdfjdfkdfdf >>> > Code now: >>> > // BEGIN -------- >>> > URLFetchService urlFetchService= >>> > URLFetchServiceFactory.getURLFetchService(); >>> > URL url = new URL("https://www.somename.com/login.php"); >>> > HTTPRequest httpRequest = new HTTPRequest(url,HTTPMethod.POST, >>> > validateCertificate()); >>> > HTTPResponse response = urlFetchService.fetch(httpRequest); >>> > >>> > // Get site cookie >>> > // ... >>> > String cookies=null; >>> > for (HTTPHeader header : response.getHeaders()) >>> > { >>> > if (header.getName().equalsIgnoreCase("set-cookie")) { >>> > cookies = header.getValue().substring(0,42); // gets only >>> > PHPSESSID=value32characters for my server URL >>> > // prepare second HTTP request with cookie set >>> > httpRequest.setHeader(new HTTPHeader("Cookie", cookies)); >>> > } >>> > } >>> > // ... >>> > // prepare second HTTP request with cookie set >>> > >>> > >>> > httpRequest.setPayload("lang=en&login=dm2vdfT&password=vjfgd&action=login".getBytes()); >>> > response = urlFetchService.fetch(httpRequest); >>> > // END ------------------------------------------ >>> > The problem I am facing now is that it populates the login and lang >>> > fields >>> > but the password value is left blank but i do have it in the setPayload >>> > function. So i don't understand why it does not read it ? Should the >>> > password value be sent differently from the other fields ? >>> > Thanks again for you help! >>> > >>> > On Thu, Feb 24, 2011 at 5:51 PM, Philippe Beaudoin >>> > <philippe.beaud...@gmail.com> wrote: >>> >> >>> >> My guess is that the JSESSIONID (or whichever session cookie used by >>> >> the >>> >> service) that is received in the HTTPResponse of your first fetch() is >>> >> not >>> >> sent back with your second fetch. As a consequence, the service does >>> >> not >>> >> know you're logged in. Here is how I would solve it (I did not test >>> >> that >>> >> code): >>> >> // ... >>> >> HTTPResponse response = urlFetchService.fetch(httpRequest); >>> >> List<HTTPHeader> headers = response.getHeaders(); >>> >> String cookies; >>> >> for (HTTPHeader header : headers) >>> >> if ("Set-Cookie".equals(header.getName()) >>> >> cookies = header.getValue(); >>> >> httpRequest = new HTTPRequest(url,HTTPMethod.POST, >>> >> validateCertificate()); >>> >> if (cookies != null) >>> >> httpRequest.setHeader(new HTTPHeader("Cookie", cookies)); >>> >> // ... >>> >> You may run into the following issues, though: >>> >> http://code.google.com/p/googleappengine/issues/detail?id=1704 >>> >> http://code.google.com/p/googleappengine/issues/detail?id=3379 >>> >> Hope it helps, >>> >> Philippe >>> >> >>> >> -- >>> >> You received this message because you are subscribed to the Google >>> >> Groups >>> >> "Google App Engine for Java" group. >>> >> To post to this group, send email to >>> >> google-appengine-java@googlegroups.com. >>> >> To unsubscribe from this group, send email to >>> >> google-appengine-java+unsubscr...@googlegroups.com. >>> >> For more options, visit this group at >>> >> http://groups.google.com/group/google-appengine-java?hl=en. >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> > Groups >>> > "Google App Engine for Java" group. >>> > To post to this group, send email to >>> > google-appengine-java@googlegroups.com. >>> > To unsubscribe from this group, send email to >>> > google-appengine-java+unsubscr...@googlegroups.com. >>> > For more options, visit this group at >>> > http://groups.google.com/group/google-appengine-java?hl=en. >>> > >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Google App Engine for Java" group. >>> To post to this group, send email to >>> google-appengine-java@googlegroups.com. >>> To unsubscribe from this group, send email to >>> google-appengine-java+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/google-appengine-java?hl=en. >>> >> > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to google-appengine-java@googlegroups.com. > To unsubscribe from this group, send email to > google-appengine-java+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.