@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() // 投稿の一覧を取得する method = new HttpGet("http://localhost/drupal/rest/node.json") response = httpclient.execute(method) json = new JsonSlurper().parseText(response.getEntity().getContent().text) json.each { println "題名:${it.title}" println "url:${it.uri}" println "created:${new Date(Long.parseLong(it.created)*1000)}" }
動作環境
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 件のコメント:
コメントを投稿