@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.1.2') import org.apache.http.client.methods.* import org.apache.http.impl.client.* import groovy.json.* httpclient = new DefaultHttpClient() // 特定の投稿の情報を取得する nodeid = 2 method = new HttpGet("http://localhost/drupal/rest/node/${nodeid}.json") response = httpclient.execute(method) json = new JsonSlurper().parseText(response.getEntity().getContent().text) println json println "題名:${json.title}" println "本文:${json.body.und[0].value}"
動作環境
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 件のコメント:
コメントを投稿