Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
171
rated 0 times [  173] [ 2]  / answers: 1 / hits: 22716  / 12 Years ago, sun, march 11, 2012, 12:00:00

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 http://soundcloud.com/song-b/song-please or http://snd.sc/yp6VMo? I tried looking at the api documentation but I couldn't really find what I was looking for.


More From » php

 Answers
15

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



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


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



$.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'])
}
)


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.


[#86922] Friday, March 9, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
davism

Total Points: 339
Total Questions: 100
Total Answers: 100

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
;