@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() // 特定のコメントの情報を取得する cid="2" method = new HttpGet("http://localhost/drupal/rest/comment/${cid}.json") response = httpclient.execute(method) json = new JsonSlurper().parseText(response.getEntity().getContent().text) println "題名:${json.subject}" println "ユーザ:${json.name}" println "created:${new Date(Long.parseLong(json.created)*1000)}" println "内容:${json.comment_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 件のコメント:
コメントを投稿