阅读背景:

如何从标准网址中获取适当的soundcloud网址?

来源:互联网 

So right now I can grab the url from already embedded soundcloud files in embed or iframe tags and use those urls on another page and display it in fancybox. Is there a way to get the right url or display in fancybox if a user offers a typical share url such as https://soundcloud.com/song-b/song-please or https://snd.sc/yp6VMo? I tried looking at the api documentation but I couldn't really find what I was looking for.

所以现在我可以从embed或iframe标签中已经嵌入的soundcloud文件中获取url,并在另一个页面上使用这些url并将其显示在fancybox中。如果用户提供典型的共享网址,例如https://soundcloud.com/song-b/song-please或https://snd.sc/yp6VMo,有没有办法在fancybox中获取正确的网址或显示?我试着查看api文档,但我找不到我想要的东西。

4 个解决方案

#1


18  

He is trying to get html to create a Soundcloud widget, not get the API url for a track. The oEmbed method "will serve the widget embed code for any SoundCloud URL pointing to a user, group, set or a playlist" and is recommended to make sure Soundclouds changes don't break your app (as opposed making your own Flash object or iframe). You can call it with a PHP web request to

他试图让html创建一个Soundcloud小部件,而不是获取一个轨道的API网址。 oEmbed方法“将为指向用户,组,集或播放列表的任何SoundCloud URL提供小部件嵌入代码”,建议确保Soundclouds更改不会破坏您的应用程序(而不是制作您自己的Flash对象或iframe) )。您可以使用PHP Web请求来调用它

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

Or with a JSON-P call (using jQuery for convenience)

或者使用JSON-P调用(为方便起见使用jQuery)

$.getJSON('https://soundcloud.com/oembed?callback=?',
    {format: 'js', url: 'https://snd.sc/yp6VMo', iframe: true},
    function(data) {
        // Stick the html content returned in the object into the page
        $('#your_player_div').html(data['html'])
    }
)

I'm adding iframe=true so you get the new HTML5 player, omit to get the old Flash object. It also works with the .sc short urls you are using.

我正在添加iframe = true所以你得到了新的HTML5播放器,省略了获取旧的Flash对象。它也适用于您正在使用的.sc短网址。

#2


7  

you can try this for song url not for the id of song url

你可以尝试这个歌曲网址而不是歌曲网址的id

    <iframe width="100%" height="166" scrolling="no" frameborder="no"src="https://w.soundcloud.com/player/?url=https://api.soundcloud.com/elissafranceschi/war&auto_play=false&color=915f33&theme_color=00FF00"></iframe>

#3


6  

I'm not exactly sure what you're asking here, but it sounds like you might need the "resolve" API endpoint. https://developers.soundcloud.com/docs/api/resolve

我不确定你在这里问什么,但听起来你可能需要“解析”API端点。 https://developers.soundcloud.com/docs/api/resolve

Example:

例:

$ curl -v 'https://api.soundcloud.com/resolve.json?url=https://soundcloud.com/matas/hobnotropic&client_id=YOUR_CLIENT_ID'

HTTP/1.1 302 Moved Temporarily
Location: https://api.soundcloud.com/tracks/49931.json

This will give you all the track information and that should be enough for whatever you need to do. Also don't forget that there's the HTML5 widget too.

这将为您提供所有跟踪信息,这应该足以满足您的任何需要。另外不要忘记HTML5小部件也是如此。

#4


0  

I haven't tried this, modified code from here:

我没有试过这个,从这里修改代码:

<object height="81" width="100%">
   <param name="movie" value="https://player.soundcloud.com/player.swf?url=<?php echo $url; ?>&amp;g=bb"></param>
   <param name="allowscriptaccess" value="always"></param>
   <embed allowscriptaccess="always" height="81" src="https://player.soundcloud.com/player.swf?url=<?php echo $url; ?>&amp;g=bb" type="application/x-shockwave-flash" width="100%"></embed>
</object>
<a href="/go.html?url=<?php echo $url; ?>"><?php echo $url; ?></a>

分享到: