首页 文章

Zomato api url请求返回错误,指出无效的api密钥

提问于
浏览
0

我正在尝试将数据存储在zomato api中,并检查网站中生成的一些网址,例如,

<a href="https://developers.zomato.com/api/v2.1/restaurant?res_id=RESID">

https://developers.zomato.com/api/v2.1/restaurant?res_id=RESID

我收到一条错误消息:

{“code”:403,“status”:“禁止”,“消息”:“无效的API密钥”}

而这个相同的网址给出了一些关于某个餐馆的数据的json格式响应 . 另外,我生成了一个zomato API密钥 . 但是,问题 . 请让我知道我错在哪里,这样我就能纠正自己 .

谢谢 .

2 回答

  • 0

    尝试从http请求的标头传递Zomato api密钥,而不是在查询字符串中传递密钥

  • 0

    在javascript结构中,api以这种方式调用:

    $.ajax({  
    url: "https://developers.zomato.com/api/v2.1/restaurant?res_id=RESID",
    dataType: 'json',
    async: true,
    beforeSend: function(xhr){xhr.setRequestHeader('user-key', 
    'INSERT_API_KEY_HERE');},  // This inserts the api key into the HTTP header
    success: function(response) { console.log(response) } });
    

相关问题