的SoundCloud API错误NS_ERROR_DOM_BAD_URI:访问受限制的URI被拒绝(JavaScript的) [英] Soundcloud API Error NS_ERROR_DOM_BAD_URI: Access to restricted URI denied (JavaScript)

查看:235
本文介绍了的SoundCloud API错误NS_ERROR_DOM_BAD_URI:访问受限制的URI被拒绝(JavaScript的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始自己​​熟悉的SoundCloud的API,我遇到了一些麻烦。至于我可以告诉大家,我需要在 SC.initialize 是client_id。我已经使用在$ C $教程Ç学院上手,这是伟大的。现在,我其实想实现的东西我遇到了一些麻烦。结果
当我跑在$ C $我code C学院,它也正是我想要做的事。现在,我想在浏览器中运行它,我得到一个空白屏幕,但此错误:

I am just getting myself acquainted with Soundcloud's API and I am having some trouble. As far as I can tell, all I need in SC.initialize is a client_id. I have used the tutorials at Code Academy to get started and it was great. Now that I am actually trying to implement something I am running into some trouble.
When I ran my code in Code Academy, it did exactly what I wanted it to do. Now that I am trying to run it in a browser, I am getting a blank screen and this error:

NS_ERROR_DOM_BAD_URI:访问受限制的URI否认@ http://connect.soundcloud.com/sdk

NS_ERROR_DOM_BAD_URI: Access to restricted URI denied @ http://connect.soundcloud.com/sdk

之后做一些研究,我发现,这些错误都与站点prefixes。所以我试图将其更改为http:// WWW connect.soundcloud.com/sdk。但是,当我这样做,我得到一个不同的错误:

After doing some research, I have found that those errors are related to domain prefixes. So I tried changing it to http://www.connect.soundcloud.com/sdk. But when I do that, I get a different error:

SC 没有定义

AHHHH我在做什么错了?结果
我是新来使用的API,任何帮助都将是非常大大AP preciated。结果
下面是我在做什么:结果
(Jav​​aScript的)

AHHHH What am I doing wrong?!
I am new to using API's, and any help at all would be very greatly appreciated.
Here is what I am doing:
(JavaScript)

SC.initialize({
    client_id: 'hidden for privacy',
});

$(document).ready(function() {
    SC.get('/users/5577686/tracks', {limit:7}, function(tracks) {
        $(tracks).each(function(index, track) {
            $('#tracktitle').append($('<li></li>').html(track.title));
            $('#trackimage').append("<img src='" + track.artwork_url + "' />");
            $('#play').append("<a href='" + track.permalink_url + "' >" + "Play" + "</a>");
        });
    });
});

(HTML)

<!DOCTYPE HTML>
<html>
    <head>
        <script src="http://connect.soundcloud.com/sdk.js"></script>
        <script src="soundcloud.js"></script>
    </head>
    <body>
        <div id="tracktitle"></div>
        <div id="trackimage"></div>
        <div id="play"></div>
    </body>
</html>

我真的不觉得有什么不对的code,因为一切都似乎是在工作code美院。我认为这是与API的熟悉自己的问题更多。我需要做一些进一步的验证?我需要的东西不仅仅是客户端ID吗?同样我非常卡住,将AP preciate帮助有这方面的量。感谢您的阅读。

I don't really think there is anything wrong with the code, as everything seemed to be working fine in Code Academy. I think it is more of an issue with familiarizing myself with the API. Do I need to do some further authentication? Do I need something more than just the client ID? Again I am very stuck and would appreciate any amount of help on this. Thanks for reading.

(我也跟着用的编码GOOD公司的SoundCloud API集成教程一步一步,我收到完全相同的错误一起,所以这进一步证实,code可能不是问题,但在连接到API而定)

(I also followed along with Coding for GOOD's Soundcloud API Integration tutorial step-by-step and I am getting the same exact errors, so this further confirms that the code is probably not the problem, but connecting to the API may be)

推荐答案

这里的问题是,连接到正在被另一台服务器上托管的API时,您必须使用相同的协议。对于本地文件,使用文件协议(文件:// ),哪来的SoundCloud使用:的http:// 的https://

The problem here is that when connecting to an API which is being hosted on another server, you must be using the same protocol. For local files, you use the file protocol (file://), wheres soundcloud uses: http:// or https://

请按照下列步骤操作:


  1. 获取服务器(XAMPP / LAMPP / WAMPP为PHP /一般的HTML,为的NodeJS JS服务器或龙卷风为Python)

  2. 找到该协议,您的服务器使用

如果您的服务器使用了 HTTP 的协议,那么你的域必须 HTTP://soundcloud.com / ... ,但如果你的服务器使用 HTTPS 的协议,那么对于API的域必须 https://开头.... 。所以,一旦你的协议相符,那么你将能够通过API来传递数据。

If you server uses the http protocol, then your domain must be http://soundcloud.com/..., but if your server uses the https protocol, then the domain for the API must be https://..... So once you get the protocols to match, then you will be able to pass data through the API.

这篇关于的SoundCloud API错误NS_ERROR_DOM_BAD_URI:访问受限制的URI被拒绝(JavaScript的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆