I'm building an android application which use httpclient to post and retrieve data to a wordpress server.
I can't send a post data because of the invalid path in the cookie. Here's the log I retrieved:
I've searched the forum, and tried solutions given, but it still rejects the cookie from the app. Several solutions I've tried are:
<ul>
<li>set cookie policy
</li>
<li>This example (<a href="https://stackoverflow.com/questions/4291241/java-htmlunit-cant-login-to-wordpress/4364330#4364330">here</a>)</li>
<li><a href="https://stackoverflow.com/questions...ce-javas-httpclient-to-accept-invalid-cookies">This</a> solution, still no result</li>
</ul>
here's my android code so far for sending http post data
I've gone through this all day, but no results.
Can anyone help?
I can't send a post data because of the invalid path in the cookie. Here's the log I retrieved:
Code:
Cookie rejected: "BasicClientCookie[version=0,name=wordpress_654732f696815924ebd07fb96f161421,domain=[my-domain],path=/wp-content/plugins,expiry=Thu Feb 13 07:53:10 GMT+07:00 2014]".Illegal path attribute "/wp-content/plugins". Path of origin: "/api/auth/generate_auth_cookie/"
Cookie rejected: "BasicClientCookie[version=0,name=wordpress_654732f696815924ebd07fb96f161421,domain=[my-domain],path=/wp-admin,expiry=Thu Feb 13 07:53:10 GMT+07:00 2014]". Illegal path attribute "/wp-admin". Path of origin: "/api/auth/generate_auth_cookie/"
I've searched the forum, and tried solutions given, but it still rejects the cookie from the app. Several solutions I've tried are:
<ul>
<li>set cookie policy
Code:
httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY,
CookiePolicy.BROWSER_COMPATIBILITY);
<li>This example (<a href="https://stackoverflow.com/questions/4291241/java-htmlunit-cant-login-to-wordpress/4364330#4364330">here</a>)</li>
<li><a href="https://stackoverflow.com/questions...ce-javas-httpclient-to-accept-invalid-cookies">This</a> solution, still no result</li>
</ul>
here's my android code so far for sending http post data
Code:
CookieStore cookieStore = new BasicCookieStore();
httpclient.setCookieStore(cookieStore);
CookieSpecFactory csf = new CookieSpecFactory() {
@Override
public CookieSpec newInstance(HttpParams httpParams) {
return new BrowserCompatSpec(){
@Override
public void validate (Cookie cookie, CookieOrigin origin)
throws MalformedCookieException{
Log.d("COOKIE", "force validate cookie path info: " + cookie.getPath() +
", origin: " + origin.getPath());
}
};
}
};
httpclient.getCookieSpecs().register("custom_validate", csf);
httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY, "custom_validate");
HttpPost httppost = new HttpPost(url);
if(postData != null){
httppost.setEntity(postData);
}
HttpResponse response = httpclient.execute(httppost);
I've gone through this all day, but no results.
Can anyone help?