Created
January 8, 2012 13:05
-
-
Save ikikko/1578299 to your computer and use it in GitHub Desktop.
Cacooの図一括削除スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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