Skip to content

Instantly share code, notes, and snippets.

@ikikko
Created January 8, 2012 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikikko/1578299 to your computer and use it in GitHub Desktop.
Save ikikko/1578299 to your computer and use it in GitHub Desktop.
Cacooの図一括削除スクリプト
import groovy.json.*
def API_KEY = 'XXXXXXXXXXXXXXXXXXXX'
def DIAGRAMS_URL = 'https://cacoo.com/api/v1/diagrams.json'
def DELETE_DIAGRAM_URL = 'https://cacoo.com/api/v1/diagrams/'
def slurper = new JsonSlurper()
def apiKeyParameter = "apiKey=${API_KEY}"
// 削除対象の図一覧の取得
def diagrams = slurper.parseText(new URL("${DIAGRAMS_URL}?${apiKeyParameter}").text)
def targetDiagrams = diagrams.result.findAll{
it.title == 'Untitled' && it.owner.name == 'nakamura'
}
// 図の削除
targetDiagrams.each { diagram ->
print "${diagram.diagramId} : "
def response = new URL("${DELETE_DIAGRAM_URL}/${diagram.diagramId}/delete.json?${apiKeyParameter}").text
println response
}
null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment