@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.1.2') import org.apache.http.* import org.apache.http.client.* import org.apache.http.client.entity.* import org.apache.http.client.methods.* import org.apache.http.impl.client.* import org.apache.http.message.* import org.apache.http.protocol.* // ログイン httpclient = new DefaultHttpClient() method = new HttpPost("http://localhost/drupal/rest/user/login") values = [ new BasicNameValuePair("username", "drupal"), new BasicNameValuePair("password", "drupal") ] method.setEntity(new UrlEncodedFormEntity(values, HTTP.UTF_8)) response = httpclient.execute(method) println response.getStatusLine().getStatusCode() println response.getEntity().getContent().text // タクソノミーのボキャブラリーの削除 vid="3" method = new HttpDelete( "http://localhost/drupal/rest/taxonomy_vocabulary/${vid}" ) response = httpclient.execute(method) println response.getStatusLine().getStatusCode() println response.getEntity().getContent().text // ログアウト method = new HttpGet("http://localhost/drupal/user/logout") response = httpclient.execute(method) println response.getStatusLine().getStatusCode()
動作環境
groovy 1.8.4, JDK7 Update1, drupal 7.1.0, services-7.x-3.1, ctools-7.x-1.0-rc1, spyc-0.5
0 件のコメント:
コメントを投稿