【发布时间】:2017-11-23 14:44:08
【问题描述】:
我想为应用使用配方 API。我已经注册并获得了一个 API 的密钥。但是,我不知道将密钥放在 URL 中的哪个位置,因此我可以将其粘贴到浏览器中并获取 JSON 响应。 这是 Curl 请求的示例
$response = Unirest\Request::get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/findByIngredients?fillIngredients=false&ingredients=apples%2Cflour%2Csugar&limitLicense=false&number=5&ranking=1",
array(
"X-Mashape-Key" => "KEY",
"X-Mashape-Host" => "spoonacular-recipe-food-nutrition-v1.p.mashape.com"
)
);
这是我在搜索 URL 时得到的:
{
"message":"Missing Mashape application key. Go to http:\/\/docs.mashape.com\/api-keys to learn how to get your API application key."
}
如果有人知道如何使用密钥或其他方式创建完整的 URL 以在 Swift 中获取 Json 响应,我们将不胜感激。 谢谢
【问题讨论】:
-
我觉得你应该去docs.mashape.com/api-keys学习如何获取你的API应用密钥。