一个真实的请求和响应
下面是一次真实的 API 调用从头到尾的样子——你的应用发出去的请求,以及它拿回来的 JSON:
GET /forecast?city=London HTTP/1.1
Host: api.weather.com
Authorization: Bearer sk_live_8f4b2c...
Accept: application/json
{
"city": "London",
"unit": "celsius",
"current": {
"temp": 14,
"condition": "cloudy"
},
"forecast": [
{ "day": "Mon", "high": 16, "low": 9 },
{ "day": "Tue", "high": 18, "low": 11 }
]
}
那行 Authorization 就是下一个话题——也是最值得做对的那个。