Last active
June 9, 2016 14:28
-
-
Save svendahlstrand/1393471 to your computer and use it in GitHub Desktop.
Shortest way to get JSON from a SiteVision Script portlet
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
importPackage(java.net); | |
importPackage(Packages.org.apache.commons.io); | |
var url = new URL('http://search.twitter.com/search.json?q=sitevision'); | |
var connection = url.openConnection(); | |
var body = IOUtils.toString(connection.getInputStream(), 'UTF-8'); | |
var json = eval('(' + body + ')'); | |
// Print the latest tweet | |
out.println(json['results'][0]['text']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Konverterat till Nashorn :)