Created
May 20, 2016 12:39
-
-
Save grimrose/e4ffb9d4dfd50c6adba21f4541cfaefc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath "com.squareup.okhttp3:okhttp:3.2.0" | |
} | |
} | |
import okhttp3.OkHttpClient | |
import okhttp3.Request | |
import okhttp3.Response | |
import groovy.json.* | |
task okHttp << { | |
def client = new OkHttpClient() | |
def request = new Request.Builder() | |
.url("https://api.github.com") | |
.build() | |
def response = client.newCall(request).execute() | |
def body = response.body().string() | |
println body | |
println JsonOutput.prettyPrint(body) | |
def slurper = new JsonSlurper() | |
def parsed = slurper.parseText(body) | |
println parsed.emojis_url | |
def emoReq = new Request.Builder().url(parsed.emojis_url).build() | |
def emoRes = client.newCall(emoReq).execute() | |
def emoBody = emoRes.body().string() | |
println JsonOutput.prettyPrint(emoBody) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment