【发布时间】:2016-09-12 16:53:14
【问题描述】:
谁能指出我正确的方向或演示如何在没有 Unirest 的情况下使用 API 密钥向 Mashape 发出请求?
我希望简单地使用 HttpURLConnection 类或 Android REST 库(如 OkHttp 或 Volley)向 Mashape API 发出 JSON 请求,但我不知道如何构造请求,或者如果不使用 Mashape 的 Unirest 甚至可能图书馆。
这是他们推荐的创建 Unirest 请求的方式:
HttpResponse<JsonNode> response = Unirest.get("https://wordsapiv1.p.mashape.com/words/incredible/definitions")
.header("X-Mashape-Key", "**********apikey************")
.header("Accept", "application/json")
.asJson();
我试图避免 Unirest,因为设置起来似乎很痛苦,并且因为伟大的 CommonsWare 自己表示应该避免在 Android 上使用 Unirest: Does anyone have an example of an android studio project that import Unirest via gradle?
在这个问题中,我实际上是在尝试使用与初学者相同的 api 和相同的情况: Trying to fetch JSON with Android using Unirest
【问题讨论】:
标签: android android-studio mashape