简体   繁体   中英

How to check validity of the embed link

Im displaying random embed links stored in the database. These embeds are linking to some music on mixcloud.com and soundcloud.com servers. But users can delete their music, so some of these embeds can become nonfunctional. For example this mixcloud embed I have in my database:

<iframe frameborder="0" height="200" 
src="//www.mixcloud.com/widget/iframe/?feed=http%3A%2F%2Fwww.mixcloud.com%2Fmeik-sebastien-muller%2Fclickclack%2F&amp;
embed_uuid=3064105d-9dbc-4907-b999-8c7076a19ca8&amp;
stylecolor=&amp;
embed_type=widget_standard&amp;
hide_cover=" 
width="480">
</iframe>

Or soundcloud embed:

<iframe frameborder="no" height="166" scrolling="no"     
src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F86361501&amp;
show_artwork=true" 
width="100%">
</iframe>

Is there some way how to check if the music on the server is still there so if the music is already deleted, I can select another embed from database?

I think It's possible with api,

$.getJSON("https://api.soundcloud.com/tracks/86361501?client_id=0f8fdbbaa21a9bd18210986a7dc2d72c&format=json").error(function() {
   alert("ups, there is an error, that track is not available");
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM