所以现在我可以从 embed 或 iframe 标签中已经嵌入的 soundcloud 文件中获取 url,并在另一个页面上使用这些 url 并将其显示在 fancybox 中。如果用户提供典型的共享 url,例如http://soundcloud.com/song-b/song-please
or ,有没有办法获得正确的 url 或在 fancybox 中显示http://snd.sc/yp6VMo
?我尝试查看 api 文档,但我真的找不到我要找的东西。
问问题
22364 次
4 回答
18
他正在尝试获取 html 来创建 Soundcloud 小部件,而不是获取曲目的 API url。oEmbed方法“将为任何指向用户、组、集或播放列表的 SoundCloud URL 提供小部件嵌入代码”,建议确保 Soundclouds 更改不会破坏您的应用程序(而不是制作您自己的 Flash 对象或 iframe )。您可以使用 PHP Web 请求调用它
http://soundcloud.com/oembed?format=js&url=[escaped_url]&iframe=true
或者使用 JSON-P 调用(为方便起见使用 jQuery)
$.getJSON('http://soundcloud.com/oembed?callback=?',
{format: 'js', url: 'http://snd.sc/yp6VMo', iframe: true},
function(data) {
// Stick the html content returned in the object into the page
$('#your_player_div').html(data['html'])
}
)
我正在添加 iframe=true 以便您获得新的 HTML5 播放器,省略获取旧的 Flash 对象。它也适用于您正在使用的 .sc 短网址。
于 2012-03-12T21:45:10.327 回答
8
你可以试试这个歌曲网址而不是歌曲网址的ID
<iframe width="100%" height="166" scrolling="no" frameborder="no"src="http://w.soundcloud.com/player/?url=http://api.soundcloud.com/elissafranceschi/war&auto_play=false&color=915f33&theme_color=00FF00"></iframe>
于 2013-05-06T14:36:57.157 回答
6
我不确定你在这里问什么,但听起来你可能需要“解决”API 端点。http://developers.soundcloud.com/docs/api/resolve
例子:
$ curl -v 'http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/matas/hobnotropic&client_id=YOUR_CLIENT_ID'
HTTP/1.1 302 Moved Temporarily
Location: http://api.soundcloud.com/tracks/49931.json
这将为您提供所有轨道信息,这对于您需要做的任何事情都足够了。也不要忘记还有HTML5 小部件。
于 2012-03-11T21:32:51.747 回答
0
我没有尝试过,从这里修改代码:
<object height="81" width="100%">
<param name="movie" value="http://player.soundcloud.com/player.swf?url=<?php echo $url; ?>&g=bb"></param>
<param name="allowscriptaccess" value="always"></param>
<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=<?php echo $url; ?>&g=bb" type="application/x-shockwave-flash" width="100%"></embed>
</object>
<a href="<?php echo $url; ?>"><?php echo $url; ?></a>
于 2012-03-11T09:29:29.017 回答