so far as I can tell my issue is that my GET request is not authorised. But my attempts to add authorisation in headers or as values in the URL (api key, username, password) are not being successful.

据我所知,我的问题是我的GET请求未经授权。但是我尝试在标头中添加授权或在URL(api密钥,用户名,密码)中添加值是不成功的。

eg.

例如。

$.ajax({
  type: 'get',
  async:   false,
  beforeSend: function(xhr){
    xhr.setRequestHeader('Authorization', 'Basic encodedusername:passwordhere');
  },
  url: "https://api.pingdom.com/api/2.0/checks",
  success: function(Data) {
    console.log(Data);
  },
    error: function(Data) { 
  }
});

Can anyone advise as to correct Javascript syntax for interacting with the Pingdom API? I believe I'm trying to authorize incorrectly Their documentation focuses on PHP which I'm unable to use in this situation.

任何人都可以建议纠正Javascript语法与Pingdom API进行交互吗?我相信我正在尝试不正确地授权他们的文档侧重于我在这种情况下无法使用的PHP。

https://www.pingdom.com/services/api-documentation-rest/#authentication

https://www.pingdom.com/services/api-documentation-rest/#authentication

2 个解决方案

#1


0

I don't think it's possible to use the Pingdom API from Javascript in a web browser.

我不认为可以在Web浏览器中使用Javascript中的Pingdom API。

You'll need to use jsonp to get your browser to allow ajax requests across sites, but according to this response it's impossible to set headers in a jsonp request.

您需要使用jsonp让浏览器允许跨站点的Ajax请求,但根据此响应,无法在jsonp请求中设置标头。

更多相关文章

  1. 在Python中解析Yaml:检测重复的密钥
  2. ssh 免密码登录 与 密钥公钥原理讲解
  3. java 对称加密——密钥与加密后的数据存盘方式

随机推荐

  1. Android的Selector与Shape
  2. android 各个属性
  3. Android实战技巧之二十二:Android 5.1 SDK
  4. android.webkit.WebView/WebViewClient/W
  5. android 资料地址
  6. Android 5.1 API 22 所有sdk文件下载地址
  7. ANDROID 绝对布局 相对布局 Linear…
  8. Android(安卓)编译,打包、签程名详细教
  9. android 带文字的ImageButton
  10. 修改标题栏的高度