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
<[email protected]> 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
> <[email protected]> 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
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to