我是一个完全的新手,刚开始学习API。我正在尝试使用Yelp API,但似乎无法访问它。 根据文档,我应该在请求头中将API密钥放置为“Authorization: Bearer”。 我对授权不熟悉,也不确定是否做得正确。以下是我的内容:
function displayYelp() {
var URL =
"https://api.yelp.com/v3/businesses/search?term=restaurant&latitude=40.82783908257346&longitude=-74.10162448883057";
$.ajax({
url: URL,
method: "GET",
headers: {
authorization:
"bearer //My Key Goes Here",
},
}).then(function(response) {
console.log(response);
});
}
即使您无法回答我的具体问题,任何有关“授权”(Authorization)相关的帮助都将不胜感激!
Authorization: bearer [your API bearer token]
作为HTTP标头与请求一起发送到服务器。如果请求存在问题,服务器将使用错误消息和HTTP代码2xx以外的代码进行响应。RFC并不是我所说的轻松阅读,但它应该包含您需要了解有关OAuth承载令牌身份验证的所有内容。 - Alex W