-1

Is it possible to find the links in the text I have stored in my database, which start with www.soundcloud.com or http://soundcloud.com, determine, if they refer to the page with the song or not (for example soundcloud user profile) and if yes, to display soundcloud player instead of the link, like it is done on the facebook...?

4

1 回答 1

2

对的,这是可能的。

您可以使用您的 URL查询oembed服务,如下所示:

http://soundcloud.com/oembed.json?url=http://soundcloud.com/crystalfighters

然后它将返回 JSON,其中小部件的 HTML 表示为html属性

{
version: 1,
type: "rich",
provider_name: "SoundCloud",
provider_url: "http://soundcloud.com",
height: 450,
width: "100%",
title: "Crystal Fighters",
description: "http://facebook.com/crystalfighters BUY NEW ALBUM 'CAVE RAVE' NOW: hhttp://po.st/caveravebuy LIVE+DJ Bookings ex-US GregLowe@theagencygroup.com US bookings carter@windishagency.com Management info@giantmenmanagement.com",
thumbnail_url: "http://i1.sndcdn.com/avatars-000041667144-lcvdi5-t500x500.jpg?9d68d37",
html: "<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fusers%2F114019&show_artwork=true"></iframe>",
author_name: "Crystal Fighters",
author_url: "http://soundcloud.com/crystalfighters"
}

或将返回 HTTP 404,这意味着此 URL 不是有效的或公共的 SoundCloud 资源

于 2013-05-29T12:50:54.630 回答