2011-07-29 18 views
2

我提前道歉,如果這被證明是錯誤的論壇,我的查詢,但我的問題是基礎代碼,它似乎是適當的:安卓Drupal的用戶創建

對於任何人誰可能需要幫助createing Drupal用戶從Android應用程序,下面的代碼工作:

//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]", "[email protected]")); 
    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()); 
} 

不過,我有另外一個問題:當使用該形象模塊,以提供用戶註冊過程中額外的自定義字段CCK,我無法找到正確acco unt [cck_parameter]將我的android數據連接並保存到配置文件CCK字段。 (我希望有人得到我的意思:-)

有沒有人有任何這方面的專業知識,請?

回答

1

用戶是一個用戶對象,額外的配置文件值是節點對象。所以user_save函數被設計爲接受很少的參數。 關鍵是,您可以創建用戶配置文件,覆蓋用戶/註冊表單的「必填字段」狀態。 保存當前表單,並在保存用戶對象後嘗試創建新節點。

查看內容配置文件API以瞭解如何保存(它是一個node_save())內容配置文件。