Skip to content

Instantly share code, notes, and snippets.

@toshihirock
Last active August 29, 2015 14:11
Show Gist options
  • Save toshihirock/76ba8398338e70be67b2 to your computer and use it in GitHub Desktop.
Save toshihirock/76ba8398338e70be67b2 to your computer and use it in GitHub Desktop.
SlideShareから特定ユーザーのスライドのDownloadUrlを取得する
// Groovy Version: 2.3.6 JVM: 1.7.0_60 Vendor: Oracle Corporation OS: Mac OS X
@Grab(group='commons-codec', module='commons-codec', version='1.10')
url = 'https://www.slideshare.net/api/2/get_slideshows_by_user'
apiKey = 'hoge'
sharedSecret = 'fuga'
userName = 'AmazonWebServicesJapan'
//unix time
ts = System.currentTimeMillis() / 1000L
//hash
import org.apache.commons.codec.digest.DigestUtils
hash = DigestUtils.sha1Hex(sharedSecret + ts).toLowerCase()
sendUrl = "${url}?api_key=${apiKey}&ts=${ts}&hash=${hash}&username_for=${userName}"
println sendUrl
response = new URL(sendUrl).text
//println response
xml = new XmlSlurper().parseText(response)
println "slideShow count = ${xml.Slideshow.size()}"
xml.Slideshow.eachWithIndex() { obj, i ->
downloadUrl = obj['DownloadUrl']
println "downloadUrl(${i}) = ${downloadUrl}"
}
@toshihirock
Copy link
Author

  • apiKey,sharedSecretについてはSlideShareのdeveloperサイトから取得し、設定すること

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment