我正在尝试构建一个使用 Soundcloud API 的 NodeWebkit 应用程序。
但是我已经在连接/登录过程中失败了。
在 NodeWebkit 中,用户可以将应用程序安装在他硬盘上的任何位置
这样 redirect_uri 永远不会相同。
在网络服务器上托管重定向页面将不起作用。
{不同的协议(protocol)“file://”和“https://”)
我在这里尝试了 API Doku 的不同方法
http://developers.soundcloud.com/docs#authentication
但没有结果。
我如何将 Soundcloud API 与 NodewebKit 一起使用?
提前致谢。
最佳答案
在发现 NodeWebkit Issue`s 之后,我看到了这个线程: https://github.com/rogerwang/node-webkit/issues/542
它描述了一种使用 NodeWebkit IFrame 的方法: 我的代码如下所示:
var def = $.Deferred();
var $iframe = $('<iframe nwfaketop nwdisable></iframe>')
.attr('src', SoundCloud.ConnectUrl)
.load(function(e) {
var parser = document.createElement('a');
parser.href = this.contentWindow.location.href;
var search = parser.search.substr(1, parser.search.length);
var result = URLToArray(search);
if (result.error !== void 0) {
$iframe.remove();
def.reject(result.error_description);
}
if (result.code !== void 0) {
SoundCloud.LoginCode = result.code;
$iframe.remove();
def.resolve();
}
})
.appendTo($(opts.iframe));
return def;
希望对遇到同样问题的人有所帮助。
关于javascript - Soundcloud API 认证 | NodeWebkit、重定向 uri 和本地文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18783944/