//create a new HttpClient and post header
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://test.site.com/testpoint/user/register");
// TODO Auto-generated method stub
try{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add( new BasicNameValuePair("account[pass]", "cutelady"));
nameValuePairs.add( new BasicNameValuePair("account[mail]", "scarter@sgc.gov"));
nameValuePairs.add( new BasicNameValuePair("account[name]", "Samantha Carter"));
httpPost.setEntity( new UrlEncodedFormEntity(nameValuePairs));
//Execute HTTP post request
HttpResponse response = httpClient.execute(httpPost);
}catch(Exception e){
Log.e("HTTP ERROR", e.toString());
}
我已经在 android 上的 drupal 的 xml rpc 模块上尝试了此代码。我不能成功。是 xml rpc 还是 json 函数?哪个是给的?然后,您能否给我发送它的 url 路径,以便 drupal 可以接受它。我无法理解“ http://test.site.com/testpoint/user/register ”路径的含义。你知道吗?提前致谢。