0

我正在尝试将我网站上提交的 Soundcloud 链接转换为 SoundCloud HTML5 播放器。我读到 oEmbed 可以做到这一点,但我自己还没有让它工作。我知道我应该使用以下 oEmbed URL:

http://soundcloud.com/oembed?format=js&url=[escaped_url]&iframe=true

但是,我不知道该怎么办。当我有一个转义的 SoundCloud URL 并将其替换为 [escaped_url] 时,我的下一步是什么?如何准确地使用该链接来生成 SoundCloud HTML5 播放器?

4

1 回答 1

5

向该 URL 发送请求,响应将是一个 JSON 文件,其中包含创建小部件所需的所有信息。

这是一个例子:

$ curl http://soundcloud.com/oembed\?format\=js\&url\=https://soundcloud.com/spadgos\&iframe\=true                                 

({
  "version": 1.0,
  "type": "rich",
  "provider_name": "SoundCloud",
  "provider_url": "http://soundcloud.com",
  "height": 450,
  "width": "100%",
  "title": "nickf \u2603",
  "description": "",
  "thumbnail_url": "http://i1.sndcdn.com/avatars-000005187616-3e82aa-t500x500.jpg?b96a101",
  "html": "\u003Ciframe width=\"100%\" height=\"450\" scrolling=\"no\" frameborder=\"no\" src=\"http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fusers%2F6431392\u0026show_artwork=true\"\u003E\u003C/iframe\u003E",
  "author_name": "nickf \u2603",
  "author_url": "http://soundcloud.com/spadgos"
});

只需抓住html财产并将其粘贴在您的文件中,就可以了。

于 2012-09-04T22:27:08.693 回答